ethantscott
ethantscott

Reputation: 15

Syntax error in "Order by" clause - SQL in Microsoft Access

I am trying to select the 10 most recent records in this table (named "5182") in ascending order by using two select and order by statements. Access throws an error on the "order by" clause here but does not tell me which one. Any help?

I've tried to change around the names of source tables and such, but it seems to just be a nagging syntax issue.

SELECT  [5182].ID, [5182].Date, [5182].Time, [5182].Name, [5182].Si, [5182].SiAvg, [5182].SiMin, [5182].SiMax

FROM

(

SELECT *
     FROM 5182
     ORDER BY [5182].ID DESC
     LIMIT 10
)

ORDER BY [5182].ID;

I want this to display the 10 most recent records in ascending order.

Upvotes: 0

Views: 546

Answers (1)

Yogesh Sharma
Yogesh Sharma

Reputation: 50163

You need TOP clause :

SELECT t.*
FROM (SELECT TOP 10 t.*
      FROM `5182` AS t
      ORDER BY t.ID DESC
     ) AS t
ORDER BY t.ID ASC;

Upvotes: 1

Related Questions