๐ Find customers who placed orders in every month of 2025
Table: Orders
customer_id | order_date
๐ Query:
SELECT customer_id
FROM Orders
WHERE YEAR(order_date) = 2025
GROUP BY customer_id
HAVING COUNT(DISTINCT MONTH(order_date)) = 12;
๐ฏ Why this question matters:
โ Tests GROUP BY + HAVING concepts
โ Uses DISTINCT counting logic
โ Evaluates date function knowledge
๐ Pro Tip:
โ
COUNT(DISTINCT ...) is commonly used in retention & activity analysisโ Month-wise activity questions are very common in analytics interviews
๐ฅ React โค๏ธ for more advanced SQL interview questions