Write a SQL query to retrieve the top 3 customers by total purchase amount in the last 6 months.
1Times asked
Sep 2026Last seen
Sep 2026First seen
💡 Model Answer
SELECT c.customer_id, c.customer_name, SUM(o.amount) AS total_purchase
FROM customers c
JOIN orders o ON c.customer_id = o.customer_id
WHERE o.order_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
GROUP BY c.customer_id, c.customer_name
ORDER BY total_purchase DESC
LIMIT 3;
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500