Last active
March 15, 2021 19:16
-
-
Save sethdorris/2ac409d9069ebac734414acbeac063cc to your computer and use it in GitHub Desktop.
This file contains 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
WITH cte1 AS ( | |
SELECT t.* | |
, (DATEDIFF(SECOND, TriggerStart, GETUTCDATE()) / 5) AS interval | |
, ROW_NUMBER() OVER (PARTITION BY DeviceId, (DATEDIFF(SECOND, TriggerStart, GETUTCDATE()) / 5) ORDER BY DeviceId, TriggerStart) AS pn | |
FROM Triggers AS t where Id = 458 | |
) | |
SELECT * | |
FROM cte1 | |
ORDER BY DeviceId |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment