select * from 表 tem where id=(select min(id) from 表 where name=tem.name)

解决方案 »

  1.   

    或:
    select * from 表 tem where id=(select top 1 id from 表 where name=tem.name)
      

  2.   

    select * from table a where id=(select min(id) from table where name=a.name)orselect min(id) id ,name from table group by name
      

  3.   

    select * from 表 tem where id=(select top 1 id from 表 where name=tem.name order by id)
      

  4.   

    本例中,如下即可:
    Select name,min(id) as id from 表  group by name
      

  5.   

    select * from 表 aa where not exists(select 1 from 表 bb where aa.name=bb.name and aa.id>bb.id)
      

  6.   

    select * from tablename tem where id=(select min(id) from tablename where name=tem.name)
      

  7.   

    select min(id),name from table1 where name in(select distinct name from table1);