Ms-access – How to select top 10 in Access query

ms-access

My Access database table has 2 columns: name and price. I want to do a query that select the top 10 highest prices. How to do this? Thanks.

Best Answer

select top 10 Name, Price
from MyTable
order by Price desc

Updated: @Remou pointed out that:

"Access SQL selects matches, so it will select all items with the same highest prices, even if this includes more than 10 records. The work-around is to order by price and a unique field (column)."

So, if you have a unique product code column, add like so:

select top 10 Name, Price
from MyTable
order by Price desc, UniqueProductCode desc
Related Topic