Counter variables [message #39397] |
Sun, 14 July 2002 23:34 |
George V Thomas
Messages: 2 Registered: July 2002
|
Junior Member |
|
|
How can i add a counter variable inside a select statement.
Detail
I got a table with some records, while fetching the records using the select statement, i want to add a counter variable, to get the record count
|
|
|
|
Re: Counter variables [message #39407 is a reply to message #39401] |
Mon, 15 July 2002 13:38 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
In 8.1.6 and up, you can also use the analytical function row_number():
sql>select dname, row_number() over (order by dname)
2 from dept;
DNAME ROW_NUMBER()OVER(ORDERBYDNAME)
-------------- ------------------------------
ACCOUNTING 1
OPERATIONS 2
RESEARCH 3
SALES 4
|
|
|