November 10, 2006 at 11:50 am
Newbie needed help...
I have a datestamp in my database that goes to the milisecond. I need group results by the hour. I've tried the following but that just hides the results rather than grouping them.
select left(calltime,10), count(id) as total from table1
group by calltime
What I need for an output would be this:
9a-10a XXXXX
10a-11a XXXXX
And so on, please help!
November 10, 2006 at 1:01 pm
create table #tmp (id int identity, mydate datetime)
insert into #tmp (mydate) values (getDate())
select datepart(hh, mydate), count(*)
FROM #tmp
group by datepart(hh, mydate)
November 12, 2006 at 2:53 pm
Are you all set with this or do you still need some help?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply