--参考create table t1(id int identity(0,1),a varchar(10),b varchar(10))
insert t1(a,b)
select 'aa','bb'
union all select 'a1','bgb'
union all select 'aa','bb'
union all select 'a2','bb'
union all select 'aa3','beeb'
union all select 'aa','bb'
union all select 'a2','bb'select * from t1
where id  in 
(select min(id) as id from t1 group by a,b)

解决方案 »

  1.   

    select min(id) as id,item_no from Order_header
    group by item_no
    having count(*)>1结果:
    1     a01
    2     a02select max(id) as id,item_no from Order_header
    group by item_no
    having count(*)>1结果:
    3     a01
    6     a02
      

  2.   

    tryselect * from Order_header
    where id  in 
    (select min(id) as id from Order_header group by item_no)
      

  3.   

    select id, item_no, count(item_no) as item_no from Order_header
    group by id id, item_no 
    having count(item_no) > 1