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
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='女')
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='女')
谢谢各位~! victorycyz(中海) 你能给我个存储过程吗??
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
inner join (
Select sex,min(age) as age
from 表
group by sex) as b
on a.sex=b.sex and a.age=b.age
union all
select * from t a where sex='女' and age=(select min(age) from t where sex='女')
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='女')
victorycyz(中海)
你能给我个存储过程吗??
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