Friday, 10 June 2011

Hour Based - Group by SQL Query

The below query can be useful if you want to see the result with hour based information:

select convert(varchar(13), datetime, 120), count(datetime), sum(connectionduration/60.0) from T_tablename(nolock) where datetime between '2011-06-07' and '2011-06-08'
group by convert(varchar(13), datetime, 120) order by 1

No comments:

Post a Comment