假设我有一个表Production
NO Name           PRODUCER
1  NOKIA-8520     NOKIA
2  NOKIA-8210     NOKIA
3  NOKIA-8178     NOKIA
3  SIMENSE-8100   SIMENSE
4  MOTOROLA-3710  MOTOROLA
5  ALCATEL-8127   ALCATEL
6  ALCATEL-8290   ALCATEL
6  ACER-2730      ACER我现在要取出所有制造商的商品型号NAME,同一制造商只取一个NO最大的,该怎么用sql查询?

解决方案 »

  1.   

    select max(no) as no,name,producer from production group by name,producer
      

  2.   

    select t.* from producton t where no = (select max(no) from production where name = t.name)
      

  3.   

    select t.* from producton t where no = (select max(no) from production where PRODUCER = t.PRODUCER)
      

  4.   

    select   max(no)   as   no,name,producer   from   production   group   by   name,producer
      

  5.   

    select * from Production  a where no=(select max(no) from Production where PRODUCER=a.PRODUCER)
    最后一个是制造商