← Back to all projects SQL · Power BI · DecodeLab internship

DecodeLab Sales Analysis

From raw order data to findings: I explored 1,200 orders in SQL, built a Power BI dashboard, and wrote up what the numbers say.

ToolsMySQL · Power BI
RoleData Analysis Intern
Data1,200 orders · 2023–2025
OutputSQL · Dashboard · Report
$1.19MTotal revenue
1,200Orders
3,535Units sold
$488KReturned + cancelled (41%)
Walkthrough

How I approached it

Get to know the data

1,200 orders with product, quantity, price, coupon, order status and referral source. 7 products and 5 referral sources, from 2023 to 2025.

Ask questions in SQL

Wrote 12 queries to answer one question at a time: sales per product, per year, per referral source, per coupon, and by order status.

Why: SQL gives exact numbers I can use to check the dashboard against.

Build the Power BI dashboard

Charts for revenue by product, year, coupon and referral source, plus order status by product. Slicers for referral source, year and product.

Write the findings

Pulled the headline numbers and the surprises into a statistical summary report.

Step 2 · SQL

The queries behind the numbers

Open any query to see the code. Each has a copy button.

1 · Total sales for each product

Which product earns the most?

sql
select Product,sum(TotalPrice) Sales
from orders
group by product
order by Sales desc;
2 · Quantity and average sales per product

Units sold, and the average order value for each product.

sql
select Product,sum(Quantity) Amount
from orders
group by product
order by Amount desc;

select Product, avg(TotalPrice) AvgSales
from orders
group by Product
order by AvgSales desc;
3 · Revenue overall and per year

Total revenue, then how it changed from year to year.

sql
select sum(TotalPrice) Revenue
from orders;

select year, sum(TotalPrice) Sales
from orders
group by year
order by Sales desc;
4 · Referral source performance

Which marketing channels bring in orders, units and sales?

sql
select ReferralSource,count(OrderID) TotalOrders,sum(Quantity) TotalQty, sum(TotalPrice) Sales
from orders
group by ReferralSource
order by Sales desc;
5 · Discounts and coupons

Blank coupon codes become "No Discount" with coalesce and nullif, so they can be compared with real coupons.

sql
select coalesce(nullif(CouponCode, ''), 'No Discount') CouponStatus,
       count(CouponCode) Count, sum(TotalPrice) Sales
from orders
group by CouponStatus
order by Sales desc;
6 · Order status, returns and cancellations

Sales by status and product, then only the two problem statuses.

sql
select OrderStatus,Product,sum(TotalPrice) Sales, sum(Quantity) TotalQty
from orders
where OrderStatus in ("Cancelled","Returned")
group by Product,OrderStatus
order by OrderStatus ,Sales desc;
7 · Monthly sales trend

Orders, units and sales by year and month.

sql
select year, Month, count(OrderID) TotalOrders, sum(Quantity) Qty, sum(TotalPrice) Sales
from orders
group by year, Month
order by year, Month;
8 · Top product per year (window function)

row_number() ranks products inside each year, and I keep rank 1.

sql
select year, Product, Sales
from (
    select
        year,
        Product,
        sum(TotalPrice) Sales,
        row_number() over (partition by year order by sum(TotalPrice) desc) as rn
    from orders
    group by year, Product
) a
where rn = 1
order by year;
Step 3 · Dashboard

Explore it yourself

Step 4 · Findings

What I found

📉 Revenue is falling every year

2023 brought in more than half the total. 2025 looks partial, so it is not a like-for-like comparison.

YearRevenueShare
2023$519,81943.7%
2024$451,20437.9%
2025*$217,88218.3%

🪑 Chair leads, Phone trails

Chair is first in both revenue and units. Phone is last in both. The top product changes each year: Printer (2023), Chair (2024), Desk (2025).

ProductRevenueUnits
Chair$185,379562
Printer$183,590542
Laptop$181,126535
Tablet$173,930497
Monitor$163,429480
Desk$157,845508
Phone$143,606411

⚠️ 41% of revenue is at risk

Cancelled is the most common status (250 orders), and Returned is close behind (247). Together they hold $488K of revenue. The cause needs investigating.

StatusOrdersRevenue
Cancelled250$258,499
Returned247$229,714
Pending237$241,762
Shipped235$231,392
Delivered231$227,539

↩️ Which products get returned or cancelled?

Tablet has the most returned revenue, and Chair has the most cancelled revenue.

ProductReturnedCancelled
Tablet$40,497$37,697
Monitor$37,531$33,736
Laptop$37,024$41,018
Printer$33,980$36,349
Phone$28,309$26,561
Desk$27,498$36,378
Chair$24,875$46,760

📱 Instagram brings the most

Instagram drives the most orders and revenue. The Referral channel brings the least.

SourceOrdersRevenue
Instagram259$258,429
Email250$246,668
Facebook228$236,455
Google241$234,421
Referral222$212,933

🏷️ Coupons

FREESHIP is the most used coupon and earns the most. Roughly one order in four has no discount at all.

CouponOrdersSales
FREESHIP313$335,037
No discount309$322,401
WINTER15 (15% off)292$257,111
SAVE10 (10% off)286$274,356

* 2025 data is partial.