I am trying to retrieve consecutive rows where the ls_status is appearing in this order per letter eg i want to see the entries where status 'AV' is occurring prior 'VL'
in my case i need to see rows 17 and 18 in my results set: (https://i.stack.imgur.com/TALU5.png)
Below is the executed sql.
if i run both subqueries separately there is no problem but when i run the entire piece of code i receive error:
ORA-00928: missing SELECT keyword
00928. 00000 - "missing SELECT keyword"
*Cause:
*Action:
Error at Line: 9 Column: 35
Any idea why this is??
with ls_ital as
(select ls_key, ls_letter, ls_status, ls_insertdate, row_number() over (order by ls_key) as id
from letter_status_aital),
t1 as
(select ls_key, ls_letter, ls_status, ls_insertdate,
row_number() over(order by id) as rn,
id -(row_number() over(order by id)) as diff
from ls_ital
where ls_status in ('AV','VL'));
i tried to run both subqueries separately and they succeed but when i run both i get the
ORA-00928: missing SELECT keyword
00928. 00000 - "missing SELECT keyword"
*Cause:
*Action:
Error at Line: 9 Column: 35
see the results of the 1st query: enter image description here
i am not sure if i am on the right track with the query but i just need to retrieve rows 17 and 18 from the 1st screen shot that is when a status 'AV' occurs before 'VL' sequentially