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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 grouping on day query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

masterdineen
Aged Yak Warrior

United Kingdom
550 Posts

Posted - 02/06/2013 :  11:52:30  Show Profile  Reply with Quote
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

United Kingdom
550 Posts

Posted - 02/06/2013 :  11:53:59  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000