You are on page 1of 1

1.

Total sales revenue by region:

SELECT r.RegionName, SUM(s.Revenue) AS TotalRevenue

FROM Sales s

JOIN Region r ON s.RegionID = r.RegionID

GROUP BY r.RegionName

2. Sales revenue by product category and month:

SELECT p.Category, DATE_TRUNC('month', s.Date) AS Month,

SUM(s.Revenue) AS TotalRevenue

FROM Sales s

JOIN Product p ON s.ProductID = p.ProductID

GROUP BY p.Category, Month

3. Sales revenue by salesperson and quarter:

SELECT sp.SalespersonName, DATE_TRUNC('quarter', s.Date) AS Quarter,

SUM(s.Revenue) AS TotalRevenue

FROM Sales s

JOIN Salesperson sp ON s.SalespersonID = sp.SalespersonID

GROUP BY sp.SalespersonName, Quarter


4. Number of customers by region and product category:

SELECT r.RegionName, p.Category, COUNT(DISTINCT c.CustomerID) AS NumCustomers

FROM Sales s

JOIN Region r ON s.RegionID = r.RegionID

JOIN Product p ON s.ProductID = p.ProductID

JOIN Customers c ON s.CustomerID = c.CustomerID

GROUP BY r.RegionName, p.Category

You might also like