答案 0 :(得分:0)
select 'M',
sum(case when col1='M' then 1 end)+
sum(case when col2='M' then 1 end)+
sum(case when col3='M' then 1 end)+
sum(case when col4='M' then 1 end)+
sum(case when col5='M' then 1 end) as m_cnt,
'F',
sum(case when col1='F' then 1 end)+
sum(case when col2='F' then 1 end)+
sum(case when col3='F' then 1 end)+
sum(case when col4='F' then 1 end)+
sum(case when col5='F' then 1 end) as f_cnt
from your_table;