- 首先找出黑名单的user:
select id
from user
where is_blacklist = 12.然后查询email表:
select
date,
round((sum(type='no_completed') / COUNT(*)),3) as p
from email
where send_id and receive_id not in (
select id
from user
where is_blacklist = 1
)
GROUP BY date
order by date asc;其中round函数是保留几位精度;
count函数中只能传进去列,不能传条件进去;
sum函数对满足条件的进行求和,sum可以传进去if判断,也可以直接传进去条件,满足的+1;

京公网安备 11010502036488号