|
| ORDER BY on an ORDER BY |
 |
Sat, 29 Mar 2008 16:04:51 +000 |
I have a huge SQL-statement that picks the top 10 recently added columns 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:
SELECT *
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!
|
| Post Reply
|
| Re: ORDER BY on an ORDER BY |
 |
Sat, 29 Mar 2008 16:26:13 +000 |
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!
|
| Post Reply
|
| Re: ORDER BY on an ORDER BY |
 |
Sat, 29 Mar 2008 17:20:32 +000 |
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.
|
| Post Reply
|
|
|
|
|
|
|
|
|
|