SQL
All Top 50 SQL Interview Questions#37
Calculate User Confirmation Rate in SQL
MediumGoogleInterview Question #37
Asked at GoogleGiven `signups` (user_id) and `confirmations` (user_id, action where action is 'confirmed' or 'timeout'), find the confirmation rate of each user rounded to 2 decimal places. Users who did not request any confirmation messages should have a confirmation rate of 0.00.
Input Table: signups & confirmations
4 rows preview| user_id | action |
|---|---|
| 3 | timeout |
| 3 | confirmed |
| 7 | confirmed |
| 2 | NULL |
Expected Output Structure3 rows
| user_id | confirmation_rate |
|---|---|
| 2 | 0 |
| 3 | 0.5 |
| 7 | 1 |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.