QuXiangjie / Study-Review

自己欠缺的还太多了,希望通过总结每天的学习内容,整理每天的思绪来丰富自己的知识库。我想成为一名优秀的金融数据分析师,并行发展技术与商业业务。博客内容为:数理统计、财务业务、Python(数据分析及可视化)、Excel(数据分析)、SQL、英文
0 stars 0 forks source link

1934.Confirmation Rate #33

Open QuXiangjie opened 4 months ago

QuXiangjie commented 4 months ago

1934.Confirmation Rate

# Write your MySQL query statement below
select s.user_id, round(avg(if(c.action="confirmed",1,0)),2) as confirmation_rate
from Signups as s left join Confirmations as c on s.user_id= c.user_id group by user_id;

avg() function can be used to calculate the rate and even we can round(avg(if (c.action='confirmed',1,0))) to set up the condition