select 
    a.* 
from 
    表 a 
where 
    a.title in(select top 5 title from 表 order by price desc)
order by
    a.category,a.price

解决方案 »

  1.   

    select * from 表 t
    where (select count(1) from 表 where category=t.category and price>=t.price)<=5
      

  2.   


    前一个 SQL 遗漏了一个关键的条件,修正一下:
    ------------------------------------------
    select 
        a.* 
    from 
        表 a 
    where 
        a.title in(select 
                       top 5 title 
                   from 
                       表 
                   where 
                       category=a.category 
                   order by 
                       price desc)
    order by
        a.category,a.price
      

  3.   

    vivianfdlpw() 的方法不错,吼吼