Created
June 3, 2018 21:40
-
-
Save johnmackintosh/ad568a8e5bf150840065c005ca505dfa to your computer and use it in GitHub Desktop.
more succint version of sql example from row of dots post
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 * , | |
ROW_NUMBER() OVER (PARTITION BY IN_OUT, Movement_Type,Staging_Post,Movement15 ORDER BY (MovementDateTime)) * [counter] AS Movement_15_SEQNO | |
FROM ( | |
SELECT [MovementDateTime], | |
[FirstName], | |
[LastName], | |
[Ward_Dept], | |
[Staging_Post], | |
[Movement_Type], | |
[IN_OUT], | |
cast(round(floor(cast([MovementDateTime] AS float(53))*24*4)/(24*4),5) AS smalldatetime) AS Movement15, | |
(CASE WHEN IN_OUT = 'IN' THEN 1 ELSE -1 END) AS [counter] | |
FROM [SERVER].[dbo].[TABLENAME])x | |
ORDER BY MovementDateTime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment