Duration
7s
Input Tokens
1002
Output Tokens
1011
Cost
$0.00
Context
Input
Show customer names and the number of service records (as service_count) for their vehicles ordered alphabetically, only customers with service records (not 0)
Expected output
SELECT c.name, COUNT(*) AS service_count FROM customers c JOIN sales s ON c.customer_id = s.customer_id JOIN service_records sr ON s.vehicle_id = sr.vehicle_id GROUP BY c.name ORDER BY c.name;
Model output
SELECT T1.name, COUNT(T3.record_id) AS service_count FROM customers AS T1 INNER JOIN sales AS T2 ON T1.customer_id = T2.customer_id INNER JOIN service_records AS T3 ON T2.vehicle_id = T3.vehicle_id GROUP BY T1.customer_id, T1.name ORDER BY T1.name;