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 |
Nice SOP
Starting Member
1 Post |
Posted - 2013-07-09 : 16:29:31
|
I have a database containing server populations at 5 minute intervals(logged as timestamp). I want to return a chart containing only the highest server poulation from each day. How would I code this task? |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-07-09 : 16:34:06
|
quote: Originally posted by Nice SOP I have a database containing server populations at 5 minute intervals(logged as timestamp). I want to return a chart containing only the highest server poulation from each day. How would I code this task?
SELECT *FROM( SELECT *, ROW_NUMBER() OVER (PARTITION BY Date ORDER BY POPULATION DESC) AS RN FROM YourServerPopulationTable) s WHERE RN = 1; |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-10 : 03:13:44
|
[code]SELECT *FROM(SELECT ROW_NUMBER() OVER (PARTITION BY DATEDIFF(dd,0,[timestamp]) ORDER BY POPULATION DESC) AS Seq,*FROM Table )tWHERE Seq=1[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-07-10 : 03:24:18
|
A timestamp is NOT a datatype used for temporal data. It is a version mechanism.Can you please clarify your table structure? N 56°04'39.26"E 12°55'05.63" |
|
|
|
|
|