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 > Adding a line number to SQL Output

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-13-04, 15:04
jhimes jhimes is offline
Registered User
 
Join Date: Feb 2004
Posts: 10
Question Adding a line number to SQL Output

Guess I am going brain dead at the momnet!

I want to add a line number to a simple SQL query so the output would look something like:

1 Output of the select statement
2 Output of the select statement
3 Output of the select statement

My current statement is basically:

Select field1, field2, field3, field4
From table1
where field1 = somevalue

Like I typed, very simple. I am just not finding how I should add a line number to the output.

Any help would be appreciated!
Reply With Quote
  #2 (permalink)  
Old 02-13-04, 15:09
ss659 ss659 is offline
Registered User
 
Join Date: Jan 2004
Posts: 492
Re: Adding a line number to SQL Output

Quote:
Originally posted by jhimes

Select field1, field2, field3, field4
From table1
where field1 = somevalue

Try adding rownum to your select statement.

[code]

Select field1, field2, field3, field4, rownum as count
From table1
where field1 = somevalue


Oh - yea an update to this - I assume you are on Oracle - if its another database, that probably wont work.

Last edited by ss659; 02-13-04 at 15:11.
Reply With Quote
  #3 (permalink)  
Old 02-13-04, 15:13
jhimes jhimes is offline
Registered User
 
Join Date: Feb 2004
Posts: 10
Smile Thanks!

Thank you, that is just what I needed!
Reply With Quote
  #4 (permalink)  
Old 02-13-04, 15:14
jhimes jhimes is offline
Registered User
 
Join Date: Feb 2004
Posts: 10
And yes I am on Oracle & just learning real SQL (from Microsoft Access SQL).
Reply With Quote
  #5 (permalink)  
Old 02-13-04, 15:16
ss659 ss659 is offline
Registered User
 
Join Date: Jan 2004
Posts: 492
Quote:
Originally posted by jhimes
And yes I am on Oracle & just learning real SQL (from Microsoft Access SQL).
You're welcome - Oracle is the place to be! Good luck and check back with questions because I am still always learning something new myself.
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