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.
| Author |
Topic |
|
zubair
Yak Posting Veteran
67 Posts |
Posted - 2009-08-25 : 06:10:14
|
| Hi,i have the following query that returns all the records from today:select session_id, arrival_timefrom clicky_recent_visitorswhere datediff( d,arrival_time,getdate()) = 0and clicky_site_id = 1111order by arrival_time ascreutrns the following rows..44574359 2009-08-25 00:55:00.00044583557 2009-08-25 01:15:00.00044585678 2009-08-25 01:20:00.00044601391 2009-08-25 01:54:00.00044616471 2009-08-25 02:28:00.00044633733 2009-08-25 03:08:00.00044652914 2009-08-25 03:54:00.00044652883 2009-08-25 03:54:00.00044653137 2009-08-25 03:55:00.00044653116 2009-08-25 03:55:00.00044654052 2009-08-25 03:57:00.00044701540 2009-08-25 06:20:00.00044722655 2009-08-25 07:31:00.00044725062 2009-08-25 07:38:00.00044767940 2009-08-25 09:34:00.00044770612 2009-08-25 09:41:00.00044774221 2009-08-25 09:49:00.00044775052 2009-08-25 09:51:00.00044785953 2009-08-25 10:18:00.00044789254 2009-08-25 10:25:00.00044790263 2009-08-25 10:28:00.000What I would like to do is to feed the info inot a graph where the x-axis is 24 hrs.. eg. 1am, 2am, 3am ......10pm, 11p, and in the y-axis i will have the number of sessions for that hour. basically will round up or down.so no of visitors against time.I'm struggling to maipulate the data to do this. Does anyone have aby ideas and can help?thx |
|
|
YellowBug
Aged Yak Warrior
616 Posts |
Posted - 2009-08-25 : 06:22:24
|
| You can GROUP BY the hour part of the date, if it's always just one day at a time,Something like this:select DATEPART(hh, arrival_time), count(*)from clicky_recent_visitorswhere datediff( d,arrival_time,getdate()) = 0and clicky_site_id = 1111group by DATEPART(hh,arrival_time)order by DATEPART(hh,arrival_time) |
 |
|
|
zubair
Yak Posting Veteran
67 Posts |
Posted - 2009-08-25 : 08:43:54
|
| Thanks! that helped a lot.is there a way to display the first column i.e. the hour in a format such as 11am, 12pm, 1pm etc? |
 |
|
|
|
|
|
|
|