Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    10

    Question Unanswered: 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!

  2. #2
    Join Date
    Jan 2004
    Posts
    492

    Re: Adding a line number to SQL Output

    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 16:11.

  3. #3
    Join Date
    Feb 2004
    Posts
    10

    Smile Thanks!

    Thank you, that is just what I needed!

  4. #4
    Join Date
    Feb 2004
    Posts
    10
    And yes I am on Oracle & just learning real SQL (from Microsoft Access SQL).

  5. #5
    Join Date
    Jan 2004
    Posts
    492
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •