locked
How to get records where count is above 123 seconds RRS feed

  • Question

  • User-1188570427 posted

    I have a query where it gives me the difference of each row in seconds.

    How can I do a where clause on differenceValue that is above say 125?

     SELECT DateAdd(hour, -6, [EVENT_DT]) as central, DATEDIFF(SECOND ,LAG([EVENT_DT]) OVER(ORDER BY [EVENT_DT]),[EVENT_DT]) as DifferenceValue
    FROM [UTL_EVENT_LOG]
    where SOURCE_DESC_TXT = 'Via_Successful' 
    order by EVENT_DT desc

    DateTime / difference

    2019-01-11 05:33:50.473 == 121
    2019-01-11 05:31:49.357 == 121
    2019-01-11 05:29:48.737 == 120
    2019-01-11 05:27:48.200 == 121

    Friday, January 11, 2019 11:37 AM

Answers

  • User77042963 posted
    Select central,DifferenceValue   from (
    SELECT DateAdd(hour, -6, [EVENT_DT]) as central, 
    DATEDIFF(SECOND ,LAG([EVENT_DT]) OVER(ORDER BY [EVENT_DT]),[EVENT_DT]) as DifferenceValue
    FROM [UTL_EVENT_LOG]
    where SOURCE_DESC_TXT = 'Via_Successful' 
    ) t
    WHERE DifferenceValue>123
    order by central desc

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 11, 2019 2:31 PM