php-db | 2002091
Date: 09/14/02
- Next message: Dave Smith: "Re: [PHP-DB] sending hidden value with form element"
- Previous message: Dave Carrera: "[PHP-DB] A group count question"
- In reply to: Dave Carrera: "[PHP-DB] A group count question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> 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...
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Dave Smith: "Re: [PHP-DB] sending hidden value with form element"
- Previous message: Dave Carrera: "[PHP-DB] A group count question"
- In reply to: Dave Carrera: "[PHP-DB] A group count question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

