select id=identity(int,1,1),sex,min(age) as age
into #t
from tablename
group by sexselect * from #tdrop table #t

解决方案 »

  1.   

    select * from 表 as a
    inner join (
     Select sex,min(age) as age
     from 表
     group by sex) as b
    on a.sex=b.sex and a.age=b.age
      

  2.   

    select * from t a where sex='男' and age=(select min(age) from t where sex='男')
    union all
    select * from t a where sex='女' and age=(select min(age) from t where sex='女')
      

  3.   

    create proc pp
    as
    select * from t a where sex='男' and age=(select min(age) from t where sex='男')
    union all
    select * from t a where sex='女' and age=(select min(age) from t where sex='女')
      

  4.   

    谢谢各位~!
    victorycyz(中海) 
    你能给我个存储过程吗??
      

  5.   

    create proc p_t
    as
    begin
      select id=identity(int,1,1),sex,min(age) as age into #t from tablename
      group by sex
      select * from #t
    endexec p_t