Re: GROUP BY MONTH(DateBilled) misses an entry consistently
| From: | Jason Wong | Date: | Fri, 11 Jan 2002 17:56:15 +0000 |
| Subject: | Re: GROUP BY MONTH(DateBilled) misses an entry consistently | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15666@lists.php.net to get a copy of this message | ||
On Saturday 12 January 2002 00:20, Mike Gifford wrote:
> Hello,
>
> Thanks for your quick reply.. I'm trying to improve the stats feature
> for gcdb (a pretty decent little PHP/MySQL accounting package on SF.net)
>
> On Fri, 2002-01-11 at 05:24, DL Neil wrote:
> > Have you posted all of the relevant code - for example, how the 'result'
> > is limited to three month's worth of data???
>
> I didn't provide all of the code in the initial response as it was using
> a wrapper so I didn't know how relevant it would be.. However, your
> note made me realize that I could rewrite the code without the
> wrapper.. It still worked the same way. The code stands as:
>
> $sql = " SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS
> BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY
> MONTH(DateBilled) ORDER BY DateBilled DESC";
> $monthly_result = mysql_query($sql, $db);
> $monthly_row = DBfetch_array($monthly_result);
You've already used the first row of results (without processing it).
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
/*
"I'd love to go out with you, but I did my own thing and now I've got
to undo it."
*/