Awesome q2a theme

How to get the value from the next record?

0 like 0 dislike
31 views
Hi all.

I have a query which gives me a bunch of dates

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


I need this query to get each other table with an offset of 1
what would get date of the next record and get this:

the query that is giving me my request
21.04.2016 22.04.2016 23.04.2016 24.04.2016


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
by | 31 views

3 Answers

0 like 0 dislike
by
0 like 0 dislike
Try it like this:

SELECT TRUNC (LOGS.DATETIME), LEAD (TRUNC (LOGS.DATETIME), 1, TRUNC(SYSDATE)) OVER (ORDER BY LOGS.DATETIME) NEXT_DATETIME FROM LOGS LOGS WHERE LOGS.ID = 123 ORDER BY LOGS.DATETIME;
by
0 like 0 dislike
Function LEAD what you need
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
asked Jun 12, 2019 by dishastalker
0 like 0 dislike
1 answer
asked Apr 14, 2019 by gadpaw
0 like 0 dislike
5 answers
110,608 questions
257,187 answers
0 comments
40,796 users