Key Metrics Queries
Key Metrics Queries
SELECT
SUM(quantity) AS total_quantity,
FROM Fact_Sales_table AS F
SELECT
DATE(timestamp) AS date,
SUM(quantity) AS total_quantity,
FROM Fact_Sales_table AS F
GROUP BY DATE(F.timestamp)
SELECT
SUM(quantity) AS total_quantity,
FROM Fact_Sales_table AS F
SELECT
S.location,
SUM(quantity) AS total_quantity,
FROM Fact_Sales_table AS F
GROUP BY S.location
b. Sales by region
SELECT
S.city,
SUM(quantity) AS total_quantity,
FROM Fact_Sales_table AS F
GROUP BY S.city
3.
WITH product_sales AS (
SELECT
P.product_id,
P.name,
P.category,
SUM(quantity) AS quantity_sold,
),
category_sales AS (
SELECT
category,
SUM(quantity_sold) AS category_quantity,
SUM(revenue_generated) AS category_revenue
FROM product_sales
GROUP BY category
SELECT
ps.product_id,
ps.name,
ps.category,
ps.quantity_sold,
ps.revenue_generated,
cs.category_quantity,
cs.category_revenue,
expected_sales,
FROM product_sales AS ps
5.
6.
7.
SELECT
S.location,
C.city AS region,
FROM Fact_Sales_table AS F
8.
WITH store_performance AS (
SELECT
S.store_id,
S.location,
SUM(quantity) AS total_quantity_sold,
FROM Fact_Sales_table AS F
SELECT
store_id,
location,
FROM store_performance