Loading content...
You are analyzing interaction telemetry from an online questionnaire platform.
The SurveyLog table records every user action taken on a question:
The table may include duplicate rows.
Define answer_rate for each question as: answer_rate = number of answer actions / number of show actions
Your task is to report the question with the highest answer_rate. If multiple questions share the same highest rate, return the smallest question_id.
For robustness in production-style logs, treat answer_rate as 0.0 when a question has zero show actions.
Return exactly one column named survey_log.
This problem should be solvable in both:
SurveyLog:
| id | action | question_id | answer_id | q_num | timestamp |
|----|--------|-------------|-----------|-------|-----------|
| 5 | show | 285 | null | 1 | 123 |
| 5 | answer | 285 | 124124 | 1 | 124 |
| 5 | show | 369 | null | 2 | 125 |
| 5 | skip | 369 | null | 2 | 126 |[{"survey_log":285}]Question 285 has rate 1/1 = 1.0 and question 369 has rate 0/1 = 0.0, so 285 is selected.
SurveyLog:
| id | action | question_id | answer_id | q_num | timestamp |
|----|--------|-------------|-----------|-------|-----------|
| 1 | show | 55 | null | 1 | 11 |
| 1 | answer | 55 | 700 | 1 | 12 |
| 2 | show | 55 | null | 2 | 20 |
| 3 | show | 101 | null | 1 | 30 |
| 3 | answer | 101 | 901 | 1 | 31 |
| 4 | show | 101 | null | 2 | 40 |[{"survey_log":55}]Both questions have answer rate 1/2 = 0.5. Tie-break requires the smaller question_id, so 55 is returned.
SurveyLog:
| id | action | question_id | answer_id | q_num | timestamp |
|----|--------|-------------|-----------|-------|-----------|
| 8 | answer | 400 | 77 | 1 | 100 |
| 8 | skip | 400 | null | 1 | 101 |
| 9 | show | 320 | null | 2 | 102 |
| 9 | skip | 320 | null | 2 | 103 |
| 9 | show | 250 | null | 3 | 104 |
| 9 | answer | 250 | 88 | 3 | 105 |[{"survey_log":250}]Question 400 has zero show actions, so its rate is treated as 0.0. Question 250 has rate 1/1 = 1.0 and wins.
Constraints