Want to create serial numbers

2020-05-08 07:20发布

I want to generate the serial no.s

e.g.

I have,

NID
----- 
ABD90
BGJ89
HSA76

and I want,

ID NID
---------
1  ABD90 
2  BGJ89
3  HSA76

What code should I run for this outcome? Please help me.

1条回答
做自己的国王
2楼-- · 2020-05-08 08:02

Since you tagged SAS, I'll answer with SAS.

Based on your question, getting that result from that input would be as simple as this

data result;
  ID=_N_;
  set input;
run;

or

proc sql;
  select ID as monotonic()
        ,NID
  from input
  ;
quit;

In pure Oracle you would do this

select rownum, NID
from input

However you might want to throw on ORDER BY in there because you'll likely get different results every time you run that.

查看更多
登录 后发表回答