Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a table like the one below:
it has a sequential ID_MOV, and an ID_DOC that is repeated because it occurs in several stages, I have a flag 1 and it is necessary that all values below this flag in the same ID_DOC have the number 1. The values with ID_MOV smaller than the flag.
Temp:
load
ID_DOC
,ID_MOV
,flag
From SomeSource;
NOCONCATENATE
Main:
Load
ID_DOC
,ID_MOV
,if(ID_DOC=Previous(ID_DOC),Peek(flag_new),flag) as flag_new
Resident Temp
Order by ID_DOC,ID_MOV ASC;
Drop table Temp;
Temp:
load
ID_DOC
,ID_MOV
,flag
From SomeSource;
NOCONCATENATE
Main:
Load
ID_DOC
,ID_MOV
,if(ID_DOC=Previous(ID_DOC),Peek(flag_new),flag) as flag_new
Resident Temp
Order by ID_DOC,ID_MOV ASC;
Drop table Temp;
Thanks man!