select z_id,z_name, student_name,birthday from table_a x where not exists(select 1 from table_a where z_id=x.z_id and birthday<x.birthday)
可以先分组,再表连接,还有到底是最大还是最小这里先按你语句里的min取最小,要是取最大把min改为maxselect z_id,z_name, student_name, birthday from table_a where (z_id,birthday) in (select select z_id, max(birthday) from table_a group by z_id );
select z_id, z_name, studet_name from (select t.* ROW_NUMBER() OVER(PARTITION BY t.z_id ORDER BY t.birthday DESC) RANK_NUM from table_a t) where rank_num = 1
select z_id, z_name, studet_name from (select t.*, ROW_NUMBER() OVER(PARTITION BY t.z_id ORDER BY t.birthday DESC) RANK_NUM from table_a t) where rank_num = 1 不好意思,刚才少写了个逗号
where not exists(select 1 from table_a where z_id=x.z_id and birthday<x.birthday)
可以先分组,再表连接,还有到底是最大还是最小这里先按你语句里的min取最小,要是取最大把min改为maxselect z_id,z_name, student_name, birthday from table_a where (z_id,birthday) in
(select select z_id, max(birthday) from table_a group by z_id );
from (select t.* ROW_NUMBER() OVER(PARTITION BY t.z_id ORDER BY t.birthday DESC) RANK_NUM
from table_a t)
where rank_num = 1
from (select t.*,
ROW_NUMBER() OVER(PARTITION BY t.z_id ORDER BY t.birthday DESC) RANK_NUM
from table_a t)
where rank_num = 1
不好意思,刚才少写了个逗号