Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I need to restart autonumber for multiple columns, but the autonumber gives same output number if the value exists in other column. Can you suggest any alternate function. Thank you.
In below, if you see for value "200" the autonumber is 3 and it is assigned wherever I have 200 across the columns. Let me know if I can use any other function or how I can reset the autonumber counter back to 1.
ID a1 a1_Autonum n1 ni_autonum
1 100 1 200 3
2 200 3 150 9
base:
load * Inline [
id, a1, n1, r1
1,100, 200, 300
2,200, 150, 240
3,250, 101, 750
4,600, 150, 225
5,1000, 845, 990
6,101, 1234, 8954
7,200, 345, 675
8,600, 750, 101
9,550, 350, 605
10,500, 185, 230
];
let c = NoOfRows('base');
test1:
load *,AutoNumber(a1) as a1rnk, $(c) as cnt
resident base
order by a1;
test:
load *,'' as samplecolumn resident test1;
drop table test1;
test2:
load AutoNumber(n1) as n1rnk, id, 'test2' as test2
resident base
order by n1;
left join (test)
load n1rnk, id resident test2;
drop table test2;
drop table base;
exit script;
You could add a second parameter to autonumber() to apply the logic to different fields - for details take a look into the help.
Beside them I'm not sure that a joining over autonumber-fields will lead to your expected results ...
- Marcus