Select County, sum (First Child _ male), sum (First Child _ female), sum (Second Child _ male), sum (Second Child _ female ), sum (more than three children _ male), sum (more than three children _ female) from (select case when children = 1 and Gender = 'male' then 1 else 0 end as first child _ male, case when children = 1 and Gender = 'female' then 1 else 0 end as first child _ female, case when children = 2 and Gender = 'male' then 1 else 0 end as second child _ male, case when children = 2 and Gender = 'female' then 1 else 0 end as second child _ female, case when children> 2 and Gender = 'male' then 1 else 0 end as more than three children _ male, case when children> 2 and Gender = 'femal' then 1 else 0 end as three children and above _ female, residence _ County as County District from birth Population Registration Form) as T group by T. county/district
The last generated execl File