Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
Here is a simple load :
Temp: LOAD * INLINE [ id, field, counter 1, bla,0 1, bla,0 1, bla,0 2, bla,0 2, bla,0 2, bla,0 3, bla,0 3, bla,0 ]; Temp2: LOAD id, field, IF (peek(id)<>id,1, peek(counter) + 1) AS counter2 RESIDENT Temp ORDER BY id; drop table Temp; |
I try to get a counter which reset for each new id find
I get only 1 for each new id, but it doesn't increment when he find 2 same id :
Any idea ?
Thanks
Temp:
LOAD * INLINE [
id, field, counter
1, bla,0
1, bla,0
1, bla,0
2, bla,0
2, bla,0
2, bla,0
3, bla,0
3, bla,0
];
Temp2:
LOAD
id,
field,
IF (Previous(id)<>id,1, peek(counter2) + 1) AS counter2
RESIDENT Temp
ORDER BY id;
drop table Temp;
IF (peek(id)<>id,1, peek('counter2') + 1) AS counter2
or
IF (peek(id)<>id,1, peek(counter2) + 1) AS counter2
Thank you,
I tried the solution unfortunatly it does not work hen I rename my column :
For example if I write this :
Temp2:
LOAD
id as toto,
field,
//IF (peek(id)<>id,1, peek(counter) + 1) AS counter2
IF (peek(id)<>id,1, peek('counter2') + 1) AS counter2,
peek(id) as previousvalue
RESIDENT Temp
ORDER BY id;
drop table Temp;
the result is :
because I add as toto
Thank you for your help
Temp:
LOAD * INLINE [
id, field, counter
1, bla,0
1, bla,0
1, bla,0
2, bla,0
2, bla,0
2, bla,0
3, bla,0
3, bla,0
];
Temp2:
LOAD
id,
field,
IF (Previous(id)<>id,1, peek(counter2) + 1) AS counter2
RESIDENT Temp
ORDER BY id;
drop table Temp;
one more easier way
Temp:
LOAD
*,
AutoNumber(RecNo(),id) as counter22
INLINE [
id, field, counter
1, bla,0
1, bla,0
1, bla,0
2, bla,0
2, bla,0
2, bla,0
3, bla,0
3, bla,0
];