I am trying to create a SELECT statement that will take a date/time field, compare the second
record with the first record, select it if the second record's time is greater than the first
record's time by 15 minutes or more, then do the same comparison for the next record and its
previous record through the entire result set.
The values returned by analytic functions can not be used in the WHERE, GROUP BY or ORDER BY clauses of the query in which they were computed. Since we want to do just that (use the value returned by LAG in a WHERE clause), we have to compute the value in a sub-query:
This was first published in April 2004