如果只有这两个字段,很简单,group by 加 min就行了,如果多于这两个字段,请参考
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=6420

解决方案 »

  1.   

    select name,min(price) as price from tA group by name
      

  2.   

    楼上,这样列出的内容name和price是对不上的请问就我举的例子,达到我的效果SQL怎么写呢?
      

  3.   

    select * from ta order by price desc
    第一行就是最小价格的商品
      

  4.   

    实际应用中不对
    我实际还有一些字段,照你的写法这样select xxx,xxx,xx,xxx,name,min(price) as price from shop group by name;列出的结果是不正确的..
      

  5.   

    select XXX,XXX,XXX,name,(select min(price) from shop a where a.name=b.name)
    from shop b
    使用子查詢聚合
      

  6.   

    lxf_1976(小木) ( ):
    请参考
    http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=6420
      

  7.   

    select * from tablename a
    where
       not exists
        (select * from tablename b
         where 
         a.name = b.name
         and
         a.price < b.price
         )
      

  8.   

    select * form tablename
    where price in
    (select min(price) from tablename)
      

  9.   

    上面错了
    select * from tablename
    where price in
    (select min(price) from tablename group by name)
    group by name
      

  10.   

    select name,min(price) as prices 
    from tA 
    group by name
    having prices<=all(
                     selcet min(prince)
                     from ta
                     group by name
                     )