5 Most Asked SQL Interview Question
5 Most Asked SQL Interview Question
SELECT product_category,
AVG(order_value) AS avg_order_value
FROM orders
GROUP BY product_category;
2️⃣. Find the top 3 customers who have spent the most money in the past year.
SELECT customer_id,
SUM(amount) AS total_spending
FROM transactions
WHERE transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR)
GROUP BY customer_id
ORDER BY total_spending DESC
LIMIT 3;
3️⃣. Count the number of orders placed in the previous year and month.
4️⃣. Calculate the total sales revenue for the past quarter.
5️⃣. Determine the number of orders that have been canceled in the past year.