Mike,
Have you posted all of the relevant code - for example, how the 'result' is limited to 
three month's worth of
data???
Have you extracted the SQL from the PHP and applied it directly to the command line or 
used it in a MySQL
Management package? Was the result any different?
Please advise,
=dn

----- Original Message -----
From: "Mike Gifford" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 11 January 2002 08:12
Subject: [PHP-DB] GROUP BY MONTH(DateBilled) misses an entry consistently


> Hello
>
> I've got the following SQL Query, which consistently pulls up only 3 out
> of 4 months from the database:
>
> $sql = " SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS
> BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY
> MONTH(DateBilled) ORDER BY DateBilled ASC";
>
> This results in:
> Month: November  Number of Invoices: 17
> Month: December Number of Invoices: 22
> Month: January Number of Invoices: 15
>
> But when I do change the order of the query from ASC to DESC like this:
>
> $sql = " SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS
> BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY
> MONTH(DateBilled) ORDER BY DateBilled ASC";$sql = " SELECT
> COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth,
> YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled)
> ORDER BY DateBilled DESC";
>
> I get:
> Month: December  Number of Invoices: 22
> Month: November Number of Invoices: 17
> Month: October Number of Invoices: 21
>
> (I gained October and Lost January)
>
> The date format in the DB is like this:
> 2001-12-05
>
> I've tried a whole stack of variations on the above query, but I still
> seem to be coming up one short.  Any idea why I'm not getting a display
> of all of the months?
>
> Thanks.
>
> Mike
> --
> Mike Gifford, OpenConcept Consulting, http://www.openconcept.ca
> Supporting progressive organizations in online campaigns and tools.
> Feature: Women's Learning Partnership http://learningpartnership.org
> Truth is that which confirms what we already believe. Northrop  Frye
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to