Last post Mar 29, 2008 01:20 PM by Mikesdotnetting
Mar 29, 2008 12:04 PM|Jiggr|LINK
I have a huge SQL-statement that picks the top 10 recently added rows from a table, for simplicity something like this:
SELECT TOP 10 someDate, username FROM table ORDER BY someDate DESC
When I have this table with the 10 rows with latest someDate I want to sort the table by username instead. I want to do something like this:
FROM (SELECT TOP 10 someDate, username FROM table ORDER BY someDate DESC) As Expr1
ORDER BY username DESC
Microsoft Access, which is the database I use, then prints the error message "Error in GROUP BY clause.
Unable to parse query text.".
How can I solve my problem?
Thanks in advice!
Mar 29, 2008 12:26 PM|wordracr|LINK
Maybe the outer order by needs to be ORDER BY Expr1.username.
Otherwise, try making a view of the inner query, and then doing SELECT * FROM vRecentUsers ORDER BY username - might work!
Mar 29, 2008 01:20 PM|Mikesdotnetting|LINK
Given that you haven't shown the offending syntax that throws the error, that makes itr difficult to offer corrective advice. However, the advice given previously is sound - create a query that gets your TOP 10 whatever, and save it. Then treat it as a
table and select from it.