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 |
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2012-02-15 : 14:23:15
|
Hello,I have a table Posts with a column Created of type Date.How can I count Posts by date range and period?For example:1 - Count, by MINUTE, the POSTS created from 10 of February to 12 of February;2 - Count, by DAY, the POSTS created from 01 of February to 15 of February;Thank You,Miguel |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2012-02-15 : 14:31:19
|
[CODE]select DateAdd(Minute, DateDiff(Minute, 0, CreatedDate), 0) Minutes, count(*) PostsPerMinutefrom Postswhere '20120210' <= CreatedDate and CreatedDate < '20120213'group by DateAdd(Minute, DateDiff(Minute, 0, CreatedDate), 0)[/CODE]=================================================Men shout to avoid listening to one another. -Miguel de Unamuno |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|