D
D
Dmitry Bashinsky2018-05-03 17:09:57
Oracle
Dmitry Bashinsky, 2018-05-03 17:09:57

How to get the value from the next entry?

Hello.
I have a query that gives me a bunch of dates

select trunc(logs.DATETIME) from Logs logs
where logs.Id = 123
order by logs.DATETIME

I need in this query how to overlay tables with an offset of 1
to get the date of the next record and get this:
query - this is what my query gives me
21.04.2016
22.04.2016
23.04.2016
24.04.2016

I want to get this:
21.04.2016 22.04.2016
22.04.2016 23.04.2016
23.04.2016 24.04.2016
24.04.2016 *sysdate*

If I have ORACLE

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mletov, 2018-05-03
@BashkaMen

https://docs.oracle.com/cd/B19306_01/server.102/b1...
www.sql-tutorial.ru/en/book_lag_and_lead_functions.html
PS Second MSSQL link, but very descriptive

D
Dmitry Bashinsky, 2018-05-04
@BashkaMen

The LEAD function is what you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question