1. Calculate the total sales for a specific time period:
SELECT SUM(sales_amount) AS total_sales
FROM sales
WHERE date BETWEEN ‚start_date‘ AND ‚end_date‘;
2. Calculate the average daily sales for a specific store:
SELECT AVG(sales_amount) AS average_daily_sales
FROM sales
WHERE store_id = ‚store_id‘;
3. Calculate the total profit margin for a specific product:
SELECT (SUM(sales_price) – SUM(cost_price)) AS total_profit_margin
FROM products
WHERE product_id = ‚product_id‘;
4. Calculate the average order value for a specific customer:
SELECT AVG(order_total) AS average_order_value
FROM orders
WHERE customer_id = ‚customer_id‘;
5. Calculate the total revenue for a specific product category:
SELECT SUM(sales_amount) AS total_revenue
FROM sales s
JOIN products p ON s.product_id = p.product_id
WHERE p.category = ‚category_name‘;