题解 | #统计每种性别的人数#
统计每种性别的人数
https://www.nowcoder.com/practice/f04189f92f8d4f6fa0f383d413af7cb8
with
data1 as (
select
count(*) as c1
from
user_submit
where
profile like "%,male"
),
data2 as (
select
count(*) as c2
from
user_submit
where
profile like "%,female"
)
SELECT
'male' AS gender,
data1.c1 AS male_count
FROM
data1
union
select
'female' AS gender,
data2.c2 AS male_count
FROM
data2;
