Hello
Could someone tell my why I get this error with the following select?
create sequence dt_test_seq start with 1 increment by 1;
create table dt_test_tab (col1 number,col2 number, col3 number);
insert into dt_test_tab values(1,1,1);
insert into dt_test_tab values(1,1,1);
insert into dt_test_tab values(1,2,2);
insert into dt_test_tab values(2,2,3);
insert into dt_test_tab values(2,2,3);
select
col1,
col2,
col3,
NVL(next_val,LAG(next_val) over(partition by col1,col2 order by col1,col2))
from
(
select
col1,
col2,
col3,
CASE
WHEN row_number() over (partition by col1,col2 order by col1,col2) = 1 THEN
dt_test_seq.nextval
END next_val
FROM
dt_test_tab
);
I came across the problem while trying to come up with a single query answer to the post:
923997
The inner query works fine but the error comes when it is turned into an inline view and apply a function to the next_val column.
It's more out of curiosity than anything else as the answer that dmitry posted is obviously the right way to do it?
And yes, I am very bored ;-)
David