LeetCode刷题实战578:查询回答率最高的问题
解题
select question_id as survey_log from (
select
question_id,
sum(case action when 'answer' then 1 else 0 end) /
sum(case action when 'show' then 1 else 0 end) as rate
from surveyLog group by question_id order by rate desc
) as temp limit 1;
select question_id as survey_log from surveyLog
group by question_id
order by avg(action = 'answer') desc limit 1;
评论