Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is it possible to update / change the value of a variable within the load script?
Test:
LOAD * Inline [
ID, amount
1, 50
1, 100
99, 70
5, 25
5, 20
5, 10
5, 21
5, 69
];
With this data I would like to be able to sort it by ID and then amount. I'd like the load script to analyze the ID; if it repeats it should add 1, then 2, and so on. I've tried adding the data to a temporary table and using Peek() and Previous() along with a variable and counter but have had no luck. With the data provided the goal would be to the following:
ID, amount, New Value
1, 50, 11
1, 100, 12
5, 10, 51
5, 20, 52
5, 21, 53
5, 25, 54
5, 69, 55
99, 70, 991
hi
this will do the trick
Test:
LOAD * Inline [
ID, amount
1, 50
1, 100
99, 70
5, 25
5, 20
5, 10
5, 21
5, 69
];
table:
load *,num(ID&counter) as newValue;
load * , if(Previous(ID)=ID,RangeSum(peek('counter'),1),1) as counter
Resident Test
order by ID,amount;
drop Table Test;
hi
this will do the trick
Test:
LOAD * Inline [
ID, amount
1, 50
1, 100
99, 70
5, 25
5, 20
5, 10
5, 21
5, 69
];
table:
load *,num(ID&counter) as newValue;
load * , if(Previous(ID)=ID,RangeSum(peek('counter'),1),1) as counter
Resident Test
order by ID,amount;
drop Table Test;