Project 16: Analyzing Motercycle Part Sales

You’re working for a company that sells motorcycle parts, and they’ve asked with 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 card, cash, and bank transfer as payment methods. However, each payment type incurs a different fee.

The board of directors want 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, 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 sales:

ColumnData typeDescription
order_numberVARCHARUnique order number.
dateDATEDate of the order, from June to August 2021.
warehouseVARCHARThe warehouse that the order was made from— NorthCentral, or West.
client_typeVARCHARWhether the order was Retail or Wholesale.
product_lineVARCHARType of product ordered.
quantityINTNumber of products ordered.
unit_priceFLOATPrice per product (dollars).
totalFLOATTotal price of the order (dollars).
paymentVARCHARPayment method—Credit cardTransfer, or Cash.
payment_feeFLOATPercentage of total charged as a result of the payment method.

Your query output should be presented in the following format:

product_linemonthwarehousenet_revenue
product_one
product_one
product_one
product_one
product_one
product_one
product_two

In [35]:

SELECT product_line, 
CASE WHEN EXTRACT(MONTH FROM date) = 6 THEN 'June'
     WHEN EXTRACT(MONTH FROM date) = 7 THEN 'July'
     ELSE 'August'
END AS month, warehouse, 
ROUND(SUM(total * (1-payment_fee)::numeric), 2) net_revenue
FROM sales
WHERE client_type = 'Wholesale'
GROUP BY product_line, month, warehouse
ORDER BY product_line, month, net_revenue DESC;

Out[35]:

product_linemonthwarehousenet_revenue
0Breaking systemAugustCentral3009.10
1Breaking systemAugustWest2475.71
2Breaking systemAugustNorth1753.19
3Breaking systemJulyCentral3740.94
4Breaking systemJulyWest3030.39
5Breaking systemJulyNorth2568.55
6Breaking systemJuneCentral3648.14
7Breaking systemJuneNorth1472.93
8Breaking systemJuneWest1200.64
9Electrical systemAugustNorth4673.99
10Electrical systemAugustCentral3095.22
11Electrical systemAugustWest1229.45
12Electrical systemJulyCentral5521.94
13Electrical systemJulyNorth1693.06
14Electrical systemJulyWest444.98
15Electrical systemJuneCentral2875.93
16Electrical systemJuneNorth2002.30
17EngineAugustCentral9433.48
18EngineAugustNorth2300.96
19EngineJulyCentral1808.77
20EngineJulyNorth997.08
21EngineJuneCentral6483.40
22Frame & bodyAugustCentral8571.50
23Frame & bodyAugustNorth7819.95
24Frame & bodyAugustWest821.40
25Frame & bodyJulyNorth6093.11
26Frame & bodyJulyCentral3103.82
27Frame & bodyJuneCentral5060.29
28Frame & bodyJuneNorth4861.08
29Frame & bodyJuneWest2751.96
30MiscellaneousAugustNorth1823.03
31MiscellaneousAugustCentral1722.40
32MiscellaneousAugustWest805.31
33MiscellaneousJulyCentral3087.31
34MiscellaneousJulyNorth2380.63
35MiscellaneousJulyWest1145.26
36MiscellaneousJuneWest2258.20
37MiscellaneousJuneCentral1859.34
38MiscellaneousJuneNorth508.86
39Suspension & tractionAugustCentral5362.59
40Suspension & tractionAugustNorth4874.51
41Suspension & tractionAugustWest1069.99
42Suspension & tractionJulyCentral6392.23
43Suspension & tractionJulyNorth3677.21
44Suspension & tractionJulyWest2909.98
45Suspension & tractionJuneNorth7985.17
46Suspension & tractionJuneCentral3291.80
47Suspension & tractionJuneWest2348.83

Leave a comment

Hello !!! I’m Ram Rallabandi

an AI consultant and data scientist with a proven track record of delivering high-impact AI solutions. My mission is simple: transform complex AI strategies into measurable business outcomes.

→ What I Do:
I specialize in leading the end-to-end lifecycle of AI products, from ideation to technical development to successful market launch. My expertise lies in bridging the gap between technical innovation and business value to ensure that every AI initiative aligns with organizational goals.

→ How I Add Value:
☑ Drive the adoption of responsible AI practices to future-proof businesses
☑ Build scalable, high-quality AI solutions that directly address customer needs
☑ Streamline processes to connect AI demand with delivery teams efficiently
☑ Analyze market trends to position data-driven solutions for maximum impact

Why It Works:
With a strong foundation in AI, machine learning, and data science, I provide strategic insights that empower organizations to leverage cutting-edge technologies for growth. I collaborate with technical and business teams to:
↳ Define product roadmaps
↳ Manage budgets, timelines, and scopes
↳ Foster cross-functional alignment for AI-driven innovation

My Passion:
I thrive on leading AI storytelling for executive leadership and fostering collaboration across diverse teams. With deep experience in Fintech and Payments, I’m dedicated to unlocking AI’s potential to deliver business transformation and create widely adopted solutions.

Let’s connect to explore how AI can transform your business.