578. 查询回答率最高的问题 难度:中等

1、题目描述

578. 查询回答率最高的问题 难度:中等_第1张图片
来源:力扣(LeetCode)

2、解题思路

求什么比率一般都是:
(sum(case when `action` like 'answer' then 1 else 0 end) / sum(case when `action` like 'show' then 1 else 0 end)) as rate

3、提交记录

select question_id as survey_log
from(
select (sum(case when `action` like 'answer' then 1 else 0 end) / sum(case when `action` like 'show' then 1 else 0 end)) as rate,question_id
from survey_log
group by question_id
order by rate desc
limit 1) x

347ms

你可能感兴趣的:(刷题)