日期:2014-05-17 浏览次数:20933 次
 SELECT  FieldA ,
         FieldB
 FROM    ( SELECT    ROW_NUMBER() OVER ( PARTITION BY FieldA ORDER BY FieldA ) id ,
                     *
           FROM      biao
         ) b
 WHERE   id = 1
------解决方案--------------------
;with c1 as
(
select row_number() over(PARTITION BY FieldA ORDER BY FieldA) rowid,
      tb.*
from tb
)
select fieldA, fieldB
from c1
where rowid=1
------解决方案--------------------
--sql2000的话如果有ID且唯一 select FieldA,FieldB from tb a where not exists(select FieldA,FieldB from tb where a.FieldA=FieldA and a.id>id) select FieldA,FieldB from tb where id=(select min(id) from tb group by FieldA)
------解决方案--------------------
over...partition by