Created
January 24, 2016 11:48
-
-
Save bjartwolf/492c2a47e992382ad2f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT p.UpdatedUtc, p.LastReadTimeStampUtc, p.LastReadMeterValue, p.Unit, p.MeterPointId | |
FROM (SELECT UpdatedUtc, | |
LastReadTimeStampUtc, | |
LastReadMeterValue, | |
Unit, | |
MeterPointId, | |
rn = ROW_NUMBER() OVER (PARTITION BY MeterPointId ORDER BY UpdatedUtc DESC) | |
FROM AbsoluteMeterReadings | |
WHERE UpdatedUtc <= @until )as p | |
WHERE rn=1 | |
ORDER BY p.UpdatedUtc | |
OFFSET @offset ROWS | |
FETCH NEXT @pagesize ROWS ONLY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment