EXPERT RESPONSE
This query, like so many other queries dealing with
"top N" results, contains within it the thorny issue of what to
do about ties. I'm not even going to mention the issue beyond saying
that you should be prepared for the inevitable questions from your users.
In Access, you can use TOP syntax. This makes the
necessary correlated subquery a lot easier to write.
select s.id
, s.name
, s.sales
from salestable s
where s.sales
in (
select top 10
sales
from salestable
where id = s.id
order
by sales desc
)
order
by s.id
, s.sales desc
For More Information
|