You're working for a company that sells motorcycle parts, and they've asked for some help in analyzing their sales data!
They operate three warehouses in the area, selling both retail and wholesale. They offer a variety of parts and accept credit cards, cash, and bank transfer as payment methods. However, each payment type incurs a different fee.
The board of directors wants to gain a better understanding of wholesale revenue by product line, and how this varies month-to-month and across warehouses. You have been tasked with calculating net revenue for each product line and grouping results by month and warehouse. The results should be filtered so that only
"Wholesale" orders are included.
They have provided you with access to their database, which contains the following table called
|Unique order number.|
|Date of the order, from June to August 2021.|
|The warehouse that the order was made from— |
|Whether the order was |
|Type of product ordered.|
|Number of products ordered.|
|Price per product (dollars).|
|Total price of the order (dollars).|
|Percentage of |
Your query output should be presented in the following format:
-- Start coding here SELECT product_line, CASE WHEN EXTRACT('month' FROM date) = 6 THEN 'June' WHEN EXTRACT('month' from date) = 7 THEN 'July' WHEN EXTRACT('month' from date) = 8 THEN 'August' END AS month, warehouse, ROUND(SUM(total* (1-payment_fee))::numeric,2) AS net_revenue FROM sales WHERE client_type = 'Wholesale' GROUP BY product_line, warehouse, month ORDER BY product_line, month, net_revenue DESC;