select (select top 1 id from 表    
         where name=a.name and state=a.state  )
,a.name,a.state
from 表 as a 
group by a.name,a.state

解决方案 »

  1.   

    select min(id),name,state from 表 group by name,stateorselect a.* from 表 a where a.id = (select top 1 id from 表 where name=a.name and state=a.state order by id asc/desc/newid())
      

  2.   

    select min(id),name,state from 表名 group by name,state
      

  3.   

    select min(id),name,state from 表名 group by name,state
    不能理解啊 讲解一下好吗?
      

  4.   

    min(id)是最小id,是一个聚合函数,
    整个语句是查出经group by 聚合了以后的记录中id最小的一个。
      

  5.   

    select DISTINCT name,state from table
      

  6.   

    支持楼上
    SELECT DISTINCT name,state FROM table找找DISTINCT的用法
      

  7.   

    看来我描述的不清楚,不好意思:
    20050614123012   1 admin 8 2 1 0
    20050614123012      3    admin 10 2 1 0像这样的记录在表中有许多,但是第一个字段的记录值并不都一样,我们只需把重复的记录显示出一条也就行了...