wrong summation using php to read mysql database
am 21.08.2007 14:02:08 von Asembereng
want to read from a database using php commands and grouping by
timetype jobdatefrom endyear and nctype and summing the groups for
everymonth but instead it sums up for all the months. Here are the
Codes i wrote for that:
$query = mysql_query("select distinct sum(ChargeTime) as ChargeTime,
sum(Amount) as AmounT , ClientName,
JobDateFrom,JobDateTo,endYear,NcType from jobs where TimeType=0 group
by TimeType, JobDateFrom, endYear, NcType having
JobDateFrom>=Date('$startdate') and JobDateTo=('$enddate')");
thats the query i am using. Can anyone help me on this?? Its an urgent
matter. thank you!!
Re: wrong summation using php to read mysql database
am 21.08.2007 14:23:09 von Jerry Stuckle
Asembereng wrote:
> want to read from a database using php commands and grouping by
> timetype jobdatefrom endyear and nctype and summing the groups for
> everymonth but instead it sums up for all the months. Here are the
> Codes i wrote for that:
>
>
> $query = mysql_query("select distinct sum(ChargeTime) as ChargeTime,
> sum(Amount) as AmounT , ClientName,
> JobDateFrom,JobDateTo,endYear,NcType from jobs where TimeType=0 group
> by TimeType, JobDateFrom, endYear, NcType having
> JobDateFrom>=Date('$startdate') and JobDateTo=('$enddate')");
>
>
>
> thats the query i am using. Can anyone help me on this?? Its an urgent
> matter. thank you!!
>
Since you're asking how to compose a SQL query, I suggest you try a SQL
newsgroup - like comp.databases.mysql.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: wrong summation using php to read mysql database
am 21.08.2007 15:07:15 von Captain Paralytic
On 21 Aug, 13:02, Asembereng wrote:
> want to read from a database using php commands and grouping by
> timetype jobdatefrom endyear and nctype and summing the groups for
> everymonth but instead it sums up for all the months. Here are the
> Codes i wrote for that:
>
> $query = mysql_query("select distinct sum(ChargeTime) as ChargeTime,
> sum(Amount) as AmounT , ClientName,
> JobDateFrom,JobDateTo,endYear,NcType from jobs where TimeType=0 group
> by TimeType, JobDateFrom, endYear, NcType having
> JobDateFrom>=Date('$startdate') and JobDateTo=('$enddate')");
>
> thats the query i am using. Can anyone help me on this?? Its an urgent
> matter. thank you!!
Whilst you should be asking this in an SQL group...
Which of the fields
TimeType, JobDateFrom, endYear, NcType
contains months?