0

I've the following sql statement running in sql server-

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;

Now, I would like to implement same technique in MS Access database. But it gives syntax error for ROW_NUMBER() and OVER()

Is there any MS Access 2007 syntax of ROW_NUMBER() and OVER()?

s.k.paul
  • 7,099
  • 28
  • 93
  • 168

1 Answers1

0

You can do like this:

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;

Result:

Id  Name    Row
10  Test    1
9   TestTwo 2
8   Thing   3
6   Another 4
5   Anyone  5
Gustav
  • 53,498
  • 7
  • 29
  • 55