Difference of datetime column in SQL -


i have table of 20000 records. each record has datetime field. want select records gap between 1 record , subsequent record more 1 hour [condition applied on datetime field].

can 1 give me sql command code purpose.

regards

kam

this can done sub query, should work on all dbms. gordon said, date/time functions different in every one.

select t.* yourtable t t.datecol + interval '1 hour' < (select min(s.datecol) yourtable s                    t.id = s.id , s.datecol > t.datecol) 

you can replace this:

t.datecol + interval '1 hour' 

with 1 of work on every dbms:

date_add( t.datecol, interval 1 hour) dateadd(hour,1,t.datecol) 

Comments