If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > sql report

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-26-02, 02:36
manishaj manishaj is offline
Registered User
 
Join Date: Oct 2002
Posts: 1
Question sql report

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.
Reply With Quote
  #2 (permalink)  
Old 10-28-02, 07:08
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: sql report

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.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On