Hi,
I am having some "fun" :banghead: at the moment trying to work out how to compare two times on different rows. The current setup I have is:
StartDTM EndDTM VisitID
09:00:00 10:00:00 1
11:00:00 12:00:00 2
12:15:00 13:00:00 3
etc etc...
I have found a SQL Query I have tried to use, however I am having no joy. The query is such:
WITH rows AS
(
SELECT *, ROW_NUMBER() OVER (ORDER BY VisitID) AS rn
FROM Data
)
SELECT DATEDIFF("n", mc.EndDTM, mp.StartDTM)
FROM rows mc
JOIN rows mp
ON mc.rn = mp.rn - 1
Could anyone guide me on what to do please / a better solution?
Many Thanks
James
I am having some "fun" :banghead: at the moment trying to work out how to compare two times on different rows. The current setup I have is:
StartDTM EndDTM VisitID
09:00:00 10:00:00 1
11:00:00 12:00:00 2
12:15:00 13:00:00 3
etc etc...
I have found a SQL Query I have tried to use, however I am having no joy. The query is such:
WITH rows AS
(
SELECT *, ROW_NUMBER() OVER (ORDER BY VisitID) AS rn
FROM Data
)
SELECT DATEDIFF("n", mc.EndDTM, mp.StartDTM)
FROM rows mc
JOIN rows mp
ON mc.rn = mp.rn - 1
Could anyone guide me on what to do please / a better solution?
Many Thanks
James