怎么算这两个的占比,男的占比,女的占比sql,性别和个数列不去掉
参考!
with aa as
(select '男' as xb, 333 as rs
from dual
union all
select '女' as xb, 555 as rs
from dual)
select xb, rs, rs / zrs
from (select * from aa, (select sum(rs) as zrs from aa))
select case when sex='男' then gs/(select sum(sl) from a)
else gs/(select sum(sl) from a) end zb from a
select case when 性别='男' then 个数/sum(个数) end 男占比,case when 性别='女' then 个数/sum(个数) end 女占比 from 表