我在sql server中运行了以下sql语句 -
SELECT Id,Name
FROM
(
SELECT ROW_NUMBER() OVER( ORDER BY Id DESC ) AS row, Id, Name from BRS
)
AS data WHERE row BETWEEN 1 AND 5 ORDER BY Id DESC;
现在,我想在MS Access数据库中实现相同的技术。但它为ROW_NUMBER() and OVER()
是否存在ROW_NUMBER() and OVER()
的任何MS Access 2007语法?
答案 0 :(得分:0)
你可以这样做:
SELECT TOP 5
(Select Count(*) From BRS As B Where B.Id >= BRS.Id) As Row,
BRS.Id,
BRS.Name
FROM
BRS
ORDER BY
BRS.Id DESC;
结果:
Id Name Row
10 Test 1
9 TestTwo 2
8 Thing 3
6 Another 4
5 Anyone 5