Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 grouping on day query

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2013-02-06 : 11:52:30
hello there,

I am trying to select on some ticketing data, but the data column is datetime.

i want to do a select that groups by the date only.

at the moment my query looks like.

select transactionpurchasedate as 'Date', COUNT(transactionid) as 'Count'
from Ticket_Facts
group by transactionpurchasedate
order by transactionpurchasedate asc

how can i group just on date and not datetime.

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2013-02-06 : 11:53:59
its ok ive done it

brain wave

select convert(date,transactionpurchasedate) as 'Date', COUNT(transactionid) as 'Count'
from Ticket_Facts
group by convert(date,transactionpurchasedate)
order by convert(date,transactionpurchasedate) asc
Go to Top of Page
   

- Advertisement -