Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have table customer with columns date, amount, type
date, amount, type
january23, 100, 1
february23, 200, 1
march23, 400, 2
april23, 700,1
What I want is to have next table customer2
date, amount
where depending on type, you choose to write original amount from previous date of current, if type is 1,
and if type is 2, write original amount from next date from current
january23, null
february23, 100
march23, 700
april23, null
try this
tab:
load * Inline
[
date, amount, type
january23, 100, 1
february23, 200, 1
march23, 400, 2
april23, 700,1
];
tab1:
load
date,
if(type=1,previous(amount),
peek('amount',recno(),'tab')) as amount
resident tab; drop table tab;
try this
tab:
load * Inline
[
date, amount, type
january23, 100, 1
february23, 200, 1
march23, 400, 2
april23, 700,1
];
tab1:
load
date,
if(type=1,previous(amount),
peek('amount',recno(),'tab')) as amount
resident tab; drop table tab;
try this
If(Type = 1, Peek('Amount', -1), null()) as Amount