I would like to query a database using sql to show the difference in time between id 1,2,3 and so on. basically it will compare the row below it for all records. any help wo
Standard ANSI SQL solution. Should work in PostgreSQL, Oracle, DB2 and Teradata:
SELECT idcode, date_time, date_time - lag(date_time) over (order by date_time) as difference FROM your_table