문제
정답
WITH Up AS (
SELECT question_id, COUNT(question_id) AS show_count
FROM SurveyLog
WHERE action = 'show'
GROUP BY question_id
)
SELECT question_id AS survey_log
FROM (
SELECT Up.question_id, answer_count / show_count as rate FROM Up
LEFT JOIN (
SELECT question_id, COUNT(question_id) as answer_count
FROM SurveyLog
WHERE action = 'answer'
GROUP BY question_id
) AS Ans
ON Up.question_id = Ans.question_id
GROUP BY Up.question_id
ORDER BY rate DESC, question_id
) AS temp
LIMIT 1