I have a table as follows
id date_time
-- -------
1 2003-10-04 12:09:00
2 2003-10-04 13:09:00
3 2003-10-05 12:09:00
4 2003-10-05 14:09:00
5 2003-10-06 14:09:00
I want to have a count of each record in the same day. So my results should be
total date
-------
2 2003-10-04
2 2003-10-05
1 2003-10-06
Any help?try using this query:
select CONVERT(varchar(10),date_time,120) as date, count(CONVERT(varchar(10),date_time,120)) as total
from table_name
group by CONVERT(varchar(10),date_time,120)
Wednesday, March 7, 2012
GROUP BY day (with a date stamp column)
Labels:
2003-10-04,
2003-10-05,
column,
database,
date,
date_time-,
followsid,
group,
microsoft,
mysql,
oracle,
server,
sql,
stamp,
table
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment