Row numbers in query result using Microsoft Access

前端 未结 7 2208
天命终不由人
天命终不由人 2020-11-29 09:35

I always use this query in sql server to get Row number in a table:

SELECT *
FROM   (SELECT *,
               Row_number()
                 OVER(
                    


        
7条回答
  •  一生所求
    2020-11-29 10:01

    MS-Access doesn't support ROW_NUMBER(). Use TOP 1:

    SELECT TOP 1 *
    FROM [MyTable]
    ORDER BY [MyIdentityCOlumn]
    

    If you need the 15th row - MS-Access has no simple, built-in, way to do this. You can simulate the rownumber by using reverse nested ordering to get this:

    SELECT TOP 1 *
    FROM (
      SELECT TOP 15 *
      FROM [MyTable]
      ORDER BY [MyIdentityColumn] ) t
    ORDER BY [MyIdentityColumn] DESC
    

提交回复
热议问题