这样是错误的:select z_id,z_name, student_name, min(birthday) from table_a group by z_id having min(birthday)
但正确的该如何写呢?
------解决方案--------------------
可以先分组,再表连接,还有到底是最大还是最小。。。这里先按你语句里的min取最小,要是取最大把min改为max
select 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