I need to do a task in Oracle that I don't know how can I possible do this.
Ok, I need to do a SELECT when I define a autonumber sequence on-the-fly.
For example:
Select autonumber(1, 9000) as auto from some_table
And the result would be
auto
------
1
2
3
4
5
6
7
8
9
10
...
9000
This would be possible to do? Are there any oracle build in function that will help me doing this?
If you want a sequence of numbers independent of rows in an actual table, rather than numbering the returned rows (in which case look at rownum
or row_number()
), you can do:
select level as auto
from dual
connect by level <= 9000;
You can use Oracle's built in rownum
select rownum as auto, other1, other2 from some_table
For ANSI compliance, you can use ROW_NUMBER() for later versions of Oracle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With