[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql
Subject:    Re: Record Counting
From:       "ranjeet walunj" <ranjeet.walunj () gmail ! com>
Date:       2007-10-30 19:23:37
Message-ID: 529d35850710301211v29891064w49718a594ee51513 () mail ! gmail ! com
[Download RAW message or body]

> > Neil Tompkins wrote:
> > > I have a table of records all of which have a timestamp against them
> > like 2007-10-25 10:10:19, and category like red, blue etc and a unique key.
> > >
> > > Using a SELECT statement is it possible to retrieve the count and number
> > of records for each day e.g 2007-10-25 for all red, and all blue etc

Hi neil.

I would use
SELECT count(colour_field_name) AS Counter,
DATE_FORMAT(datetimecol,'%y-%m-%d') as Date, colour_field_name FROM
table_name GROUP BY Date, colour_field_name;

Regards,
Ranjeet Walunj

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=mysql-marcsub@progressive-comp.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic