SQLSQL
#23

Calculate Repeat Purchase Rate in SQL

MediumZomato
Interview Question #23
Asked at Zomato

Given an `orders` table, write a SQL query to calculate the `repeat_purchase_rate` as a percentage: (customers with > 1 order / total customers) * 100, rounded to 2 decimal places.

Input Table: orders
4 rows preview
order_idcustomer_id
1101
2101
3102
4103
Expected Output Structure1 rows
repeat_purchase_rate_pct
33.33
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us