1 Reply Latest reply: Nov 29, 2017 3:53 AM by Marcus Sommer RSS

    Reset/Restart AutoNumber function

    MONAJ RATHI

      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;