SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Evangelist compwizard's Avatar
    Join Date
    May 2002
    Location
    United States
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Number rows in a sql query

    I know that this is a little bit off topic, but is there a way in ms. Access or sql to number the rows of a query?

    ie.

    numrows field 1
    ------- -------
    1 afffdfds
    2 kjljkl
    3 hhfdfd

    I can do it in a report, but i can;t get it to work with a query. Any help would be greatly appreciated!!

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this:
    Code:
    select
      (select count(t1.id) from table as t1 where t1.id <= t2.id) as numrows, 
      t2.id as id, 
      t2.field1 as field1
    from
      table as t2
    order by 
      t2.id
    http://support.microsoft.com/directo...EN-US;Q186133&


Bookmarks

Posting Permissions

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