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.
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.
1,200 orders with product, quantity, price, coupon, order status and referral source. 7 products and 5 referral sources, from 2023 to 2025.
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.
Charts for revenue by product, year, coupon and referral source, plus order status by product. Slicers for referral source, year and product.
Pulled the headline numbers and the surprises into a statistical summary report.
Open any query to see the code. Each has a copy button.
Which product earns the most?
select Product,sum(TotalPrice) Sales from orders group by product order by Sales desc;
Units sold, and the average order value for each product.
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;
Total revenue, then how it changed from year to year.
select sum(TotalPrice) Revenue from orders; select year, sum(TotalPrice) Sales from orders group by year order by Sales desc;
Which marketing channels bring in orders, units and sales?
select ReferralSource,count(OrderID) TotalOrders,sum(Quantity) TotalQty, sum(TotalPrice) Sales from orders group by ReferralSource order by Sales desc;
Blank coupon codes become "No Discount" with coalesce and nullif, so they can be compared with real coupons.
select coalesce(nullif(CouponCode, ''), 'No Discount') CouponStatus,
count(CouponCode) Count, sum(TotalPrice) Sales
from orders
group by CouponStatus
order by Sales desc;Sales by status and product, then only the two problem statuses.
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;Orders, units and sales by year and month.
select year, Month, count(OrderID) TotalOrders, sum(Quantity) Qty, sum(TotalPrice) Sales from orders group by year, Month order by year, Month;
row_number() ranks products inside each year, and I keep rank 1.
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;2023 brought in more than half the total. 2025 looks partial, so it is not a like-for-like comparison.
| Year | Revenue | Share |
|---|---|---|
| 2023 | $519,819 | 43.7% |
| 2024 | $451,204 | 37.9% |
| 2025* | $217,882 | 18.3% |
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).
| Product | Revenue | Units |
|---|---|---|
| Chair | $185,379 | 562 |
| Printer | $183,590 | 542 |
| Laptop | $181,126 | 535 |
| Tablet | $173,930 | 497 |
| Monitor | $163,429 | 480 |
| Desk | $157,845 | 508 |
| Phone | $143,606 | 411 |
Cancelled is the most common status (250 orders), and Returned is close behind (247). Together they hold $488K of revenue. The cause needs investigating.
| Status | Orders | Revenue |
|---|---|---|
| Cancelled | 250 | $258,499 |
| Returned | 247 | $229,714 |
| Pending | 237 | $241,762 |
| Shipped | 235 | $231,392 |
| Delivered | 231 | $227,539 |
Tablet has the most returned revenue, and Chair has the most cancelled revenue.
| Product | Returned | Cancelled |
|---|---|---|
| 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 drives the most orders and revenue. The Referral channel brings the least.
| Source | Orders | Revenue |
|---|---|---|
| 259 | $258,429 | |
| 250 | $246,668 | |
| 228 | $236,455 | |
| 241 | $234,421 | |
| Referral | 222 | $212,933 |
FREESHIP is the most used coupon and earns the most. Roughly one order in four has no discount at all.
| Coupon | Orders | Sales |
|---|---|---|
| FREESHIP | 313 | $335,037 |
| No discount | 309 | $322,401 |
| WINTER15 (15% off) | 292 | $257,111 |
| SAVE10 (10% off) | 286 | $274,356 |
* 2025 data is partial.