578. Get Highest Answer Rate Question

https://leetcode.com/articles/get-highest-answer-rate-question/

SELECT question_id as survey_log FROM ( SELECT question_id, SUM(case when action="answer" THEN 1 ELSE 0 END) as num_answer, SUM(case when action="show" THEN 1 ELSE 0 END) as num_show, FROM survey_log GROUP BY question_id ) as tbl ORDER BY (num_answer / num_show) DESC LIMIT 1
posted @ 2018-10-20 03:39  ffeng0312  阅读(291)  评论(0)    收藏  举报