Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:10:38+00:00 2026-06-13T12:10:38+00:00

I have a table which looks like this. NAME AGE james 22 ames 12

  • 0

I have a table which looks like this.

NAME    AGE
james   22
ames    12
messi   32
....
....

I can query this table using Select name, age from emp;

Now what I want is having an extra column before name which will be 1,2,3..N if the query return n rows.

SEQUENCE    NAME    AGE
1    james  22
2    ames   12
3    messi  32
4    ....
    ....

How I can do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:10:39+00:00Added an answer on June 13, 2026 at 12:10 pm

    if you want to just add a column which will contain sequence number at display time(not actually store that data in a table) you can use ROWNUM pseudocolumn or row_number() analytical function.

    select row_number() over(order by name) seq
         , name
         , age
      from your_table
    
          SEQ NAME               AGE
    ---------- ----------- ----------
             1 ames                12
             2 james               22
             3 messi               32
    

    The output of the above query is ordered by NAME but you can order by any column or combination of columns you want.

    Second approach is using rownum pseudocolumn. result is ordered by name also

     select rownum seq
          , name
          , age
       from ( select name
                   , age
               from your_table
              order by name
             )
    
    
    
           SEQ NAME               AGE
    ---------- ----------- ----------
             1 ames                12
             2 james               22
             3 messi               32
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got 1 file which looks like this COMPANY=xyz system.employee[0].Name=shayam system.employee[0].Age=26 system.employee[0].sex=Male system.employee[1].Name=ram
I have a table in SQL Server which looks like this: ID Code Name
For example, I have a table which looks like this : id | name
I have a table which looks like this: id response_id name value 6 13
I have a table which looks like this: Name | Quantity | Unit -------+-------------+----------
I have a Category class which looks like this: @Entity @Table(name = categories) public
I have this query which returns all rows from a table: select Cost, Name,
I have a table which looks like this: mysql> SHOW COLUMNS FROM Users; +------------+--------------+------+-----+---------+----------------+
I have a table which looks like this: <table id='t'> <thead> .... </thead> <tbody
I have a table which looks like this one: | id | fk_book |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.