You have orders table with columns:
order_id, customer_id, city, amount, statusFind each city's: Completed order count, Unique customers, Total revenue, Average order value. Only include cities where completed revenue is greater than โน10,000. Sort by revenue from highest to lowest.
Solution:
SELECT
city,
COUNT(*) AS completed_orders,
COUNT(DISTINCT customer_id) AS unique_customers,
SUM(amount) AS revenue,
AVG(amount) AS average_order_value
FROM orders
WHERE status = 'Completed'
GROUP BY city
HAVING SUM(amount) > 10000
ORDER BY revenue DESC;
Double Tap โค๏ธ For Part-7