none
Row id in sql server....

    Pregunta

  • Hi all,
      i have a task that whenever i will write a select query then when the result comes then i should be able to write a column that should write the ROW-ID of these rows. I mean for example i write a select query that gives me the following table:(the query can be like select bill_id,name from myTable order by name)

    Bill_id

    name

    25

    abc

    18

    def

    26

    ghi

    23

    adfd

     
    but my result should look like:

    Row_Id

    Bill_id

    name

    1

    25

    abc

    2

    18

    def

    3

    26

    ghi

    4

    23

    adfd

    n this Row_Id should be generated automatically....even if when i will write order by name in reverse order then also it should write the row_id as 1,2,3,4 same increasing order...n this automatic function i have to make...i cant understand..if there exist some procedure or function that already does this...or how can i just find the simple ROW_ID in general?????
    any help will be greatly appreciated.
    Regards.
    viernes, 02 de diciembre de 2005 10:56

Respuestas

  • ok,i found the solution....here it is:

    select rank=count(*), a1.au_lname, a1.au_fname
       from authors a1, authors a2
       where a1.au_lname + a1.au_fname >= a2.au_lname + a2.au_fname
       group by a1.au_lname, a1.au_fname
       order by 1
     
    viernes, 02 de diciembre de 2005 13:45

Todas las respuestas

  • ok,i found the solution....here it is:

    select rank=count(*), a1.au_lname, a1.au_fname
       from authors a1, authors a2
       where a1.au_lname + a1.au_fname >= a2.au_lname + a2.au_fname
       group by a1.au_lname, a1.au_fname
       order by 1
     
    viernes, 02 de diciembre de 2005 13:45
  • http://www.aspfaq.com/2427 wrote in message news:4cd06c7a-358b-47eb-943e-e4e74d2d52b8@discussions.microsoft.com... > Hi all, > i have a task that whenever i will write a select query then when the > result comes then i should be able to write a column that should write > the ROW-ID of these rows. I mean for example i write a select query that > gives me the following table:(the query can be like select bill_id,name > from myTable order by name) > > Bill_id > > name > > 25 > > abc > > 18 > > def > > 26 > > ghi > > 23 > > adfd > > > but my result should look like: > > Row_Id > > Bill_id > > name > > 1 > > 25 > > abc > > 2 > > 18 > > def > > 3 > > 26 > > ghi > > 4 > > 23 > > adfd > > n this Row_Id should be generated automatically....even if when i will > write order by name in reverse order then also it should write the > row_id as 1,2,3,4 same increasing order...n this automatic function i > have to make...i cant understand..if there exist some procedure or > function that already does this...or how can i just find the simple > ROW_ID in general????? > any help will be greatly appreciated. > Regards. > >
    viernes, 02 de diciembre de 2005 13:59