select Z,count(Z) 人数 from a
left join b on a.JL=b.bh
where Z is not null
group by Z
select floor((SYSDATE - to_date(birthday,‘yyyy-mm-dd’))/365) AS AGE from temp
select sex ,count(sex) 性别 from
(select (case sex
when ‘1’ then ‘男’
when ‘2’ then ‘女’
else '未知’end)as sex
from temp)t
group by sex