How to select top 10 in Access query?

前端 未结 1 1075
逝去的感伤
逝去的感伤 2020-11-30 09:23

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条回答
  • 2020-11-30 10:08
    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
    
    0 讨论(0)
提交回复
热议问题