商品编号(No) 种类(Type)  价格(Price)

解决方案 »

  1.   

    select 种类,min(商品编号),max(价格)
    from Sp
    group by 种类 
      

  2.   

    select Type, max(Price)
    form Sp
    group by Type
    order by Type
      

  3.   

    create table test(pid int primary key identity(1,1),category varchar(20),price int)
    insert into test(category,price)values('A',6)
    insert into test(category,price)values('A',4)
    insert into test(category,price)values('A',2)
    insert into test(category,price)values('B',6)
    insert into test(category,price)values('B',5)
    insert into test(category,price)values('C',6)
    insert into test(category,price)values('C',3)select pid,category,price from test t where pid in(select top 1 pid from test where t.category=category )
      

  4.   

    select *
    from Sp
    where Type+Price in
    (
      select Type+max(Price)
      from Sp
      group by Type
    )
    order by Type
      

  5.   

    http://topic.csdn.net/u/20080123/18/9731d130-0d4b-4c11-8d89-f2c3ca331f0c.html
      

  6.   

    select *
    from Sp
    where [Type]+CAST(Price AS CHAR) in
    (
      select [Type]+CAST(max(Price) AS CHAR)
      from Sp
      group by [Type]
    )
    order by [Type]
      

  7.   

    select *
    from Sp
    where [Type]+CAST(Price AS CHAR) in
    (
      select [Type]+CAST(max(Price) AS CHAR)
      from Sp
      group by [Type]
    )
    order by [Type]
      

  8.   

    忘记了排序,应该是:
    select pid,category,price from test t where pid in(select top 1 pid from test where t.category=category order by price desc )
      

  9.   


    select *
    from Sp t
    where not exists(select * from Sp where 种类=t.种类 and 价格>t.价格)
      

  10.   


    select sp.* from sp join
    (select kind,max(price) pri from sp group by kind) b
    on sp.kind=b.kind and sp.price=b.prikind为种类,price为价格
      

  11.   

    select *
    from Sp t
    where not exists(select * from Sp where 种类=t.种类 and 价格>t.价格)