RE: [PHP-DB] A group count question

From: Date: Sat, 14 Sep 2002 20:17:44 +0000
Subject: RE: [PHP-DB] A group count question
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-21759@lists.php.net to get a copy of this message
> I have a table that I would like to show some stats based on num > messages collated to date posted. > > I think I need something like > > Count(replies) where date= month(dateposted) > > All I need is to show that say that in month 8, 500 messages were sent > and in month 9 300 messages were sent and so on. If you know the month, then you would do this: SELECT COUNT(*) FROM table WHERE MONTH(date_column) = $month; If you want a rollup for all months, then: SELECT COUNT(*) FROM table GROUP BY MONTH(date_column); If you want a rollup for the current year: SELECT COUNT(*) FROM table WHERE YEAR(date_column) = year(CURDATE()) GROUP BY MONTH(date_column) HTH ---John Holmes...

« previous php.db (#21759) next »