31
votes

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.

1
Welcome to StackOverflow. Please see the FAQ for how to ask questions here. This is not a 'Give me teh Codez' site. Also of interest may be What Have You Tried? - Brian Roach

1 Answers

57
votes
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