Quote:
Originally posted by manishaj
I have a query : - How do I generate serial nos. to the records generated by an sql command. I have used order by in the query. I want to send the result set as a report to user and need to show seial nos. in the report.
Thanks in advance.
|
It depends on your DBMS and/or reporting tool.
If you are using a cursor and fetching rows, you can just count the rows fetched yourself.
If you are using a reporting tool, it may have its own way of doing this.
If you are using Oracle, you can use ROWNUM:
SELECT ROWNUM, a, b, c FROM
( SELECT a, b, c, FROM ... ORDER BY ... );
If you are using a non-Oracle DBMS, it may have a similar facility.