You just need a union between all the possible combinations:
select 'N' as Flag1, NULL as Flag2, NULL as Flag3, NULL as Flag4, (select count(*) from table_name where Flag1='N') as count
union all
select 'Y', NULL, NULL, NULL, (select count(*) from table_name where Flag1='Y') as count
union all
select NULL, 'N', NULL, NULL, (select count(*) from table_name where Flag2='N') as count
union all
select NULL, 'Y', NULL, NULL, (select count(*) from table_name where Flag2='Y') as count
union all
select NULL, NULL, 'N', NULL, (select count(*) from table_name where Flag3='N') as count
union all
select NULL, NULL, 'Y', NULL, (select count(*) from table_name where Flag3='Y') as count
union all
select NULL, NULL, NULL, 'N', (select count(*) from table_name where Flag4='N') as count
union all
select NULL, NULL, NULL, 'Y', (select count(*) from table_name where Flag4='Y') as count