题解 | count(case when type='no_completed' then 1 end )
异常的邮件概率
http://www.nowcoder.com/practice/d6dd656483b545159d3aa89b4c26004e
SELECT
date, round(count(case when type='no_completed' then 1 end ) / COUNT(type),3) p
FROM
email
WHERE
send_id IN (
select
id
FROM
user
where
is_blacklist = 0
)
and
receive_id IN (
select
id
FROM
user
where
is_blacklist = 0
)
GROUP BY
date
ORDER BY date
date, round(count(case when type='no_completed' then 1 end ) / COUNT(type),3) p
FROM
WHERE
send_id IN (
select
id
FROM
user
where
is_blacklist = 0
)
and
receive_id IN (
select
id
FROM
user
where
is_blacklist = 0
)
GROUP BY
date
ORDER BY date