我让 sql 像这样但是第二个 select 没有正确计算行数,并且行重复

i make sql like this but second select not count rows correctly, and rows duplicated

select * from (
select distinct nationality,gender,regplacetype,count(gender) as total from population
    where date_part('year',age(to_date(dateofbirth,'DDMMYYYY'))) BETWEEN  16 and 67 and gender = 'Man'
    group by nationality,gender,regplacetype
    ) as man,
(
select distinct nationality,gender,regplacetype,count(nationality) as total from population
    where date_part('year',age(to_date(dateofbirth,'DDMMYYYY'))) BETWEEN  16 and 57 and gender = 'female'
    group by xnationality,gender,regplacetype) as female
with man as (
select distinct nationality,gender,regplacetype,count(gender) as total from population
    where date_part('year',age(to_date(dateofbirth,'DDMMYYYY'))) BETWEEN  16 and 67 and gender = 'Man'
    group by nationality,gender,regplacetype
    ) select * from man,
union
select distinct nationality,gender,regplacetype,count(nationality) as total from population
    where date_part('year',age(to_date(dateofbirth,'DDMMYYYY'))) BETWEEN  16 and 57 and gender = 'female'
    group by xnationality,gender,regplacetype