Project brief#
The management of the online shop wants a business review. You must answer their questions with SQL, check your numbers, and write short insights.
Use the editor below to explore. Each question in Practice Exercises is checked automatically against the correct result.
इस project में आप एक business analyst की तरह management के सवालों के जवाब SQL से निकालेंगे। हर सवाल का जवाब नीचे के exercises में अपने-आप जाँचा जाएगा।
तरीका: पहले tables समझें → सवाल को छोटे कदमों में तोड़ें (CTE) → हर कदम का नतीजा जाँचें → फिर अंतिम query लिखें → और आखिर में insight लिखें (नतीजा + इसका मतलब + सुझाव)।
Questions from management#
| # | Question | Exercise |
|---|---|---|
| 1 | How many delivered orders, how much revenue, and what's the average order value? | Q1 |
| 2 | Which 3 cities generate the most revenue? | Q2 |
| 3 | Which payment modes have the highest cancellation/return rate? | Q3 |
| 4 | Which category is most profitable (margin %)? | Q4 |
| 5 | Who are our most loyal customers? | Q5 |
Your checklist#
- [ ] Define revenue clearly (we use Delivered orders, after discount).
- [ ] Use
COUNT(DISTINCT order_id)after joining order_items. - [ ] Verify one number another way (e.g. revenue total = sum of category revenues).
- [ ] Write one insight per question.
Sample insights (check after solving)
- Q1: 156 delivered orders, revenue ≈ Rs. 21.2 lakh, AOV ≈ Rs. 13,598.
- Q2: Nagpur, Bhubaneswar and Lucknow lead - none of them metro cities. Insight: tier-2 cities deserve marketing attention.
- Q3: Cash has the highest problem rate (≈ 16.7%); UPI, Card and COD are around 10-11%. Net Banking shows 0%, but with only 11 orders - be careful drawing conclusions from small samples.
- Q4: Office Supplies ≈ 39% margin, Furniture ≈ 25%, Technology ≈ 10% - Technology brings revenue, others bring profit. Bundle accessories with phones/laptops.
- Q5: 26 customers have ordered 5 or more times - most of the active base. A loyalty programme for them protects the majority of repeat revenue.
Now the real thing - Olist e-commerce database (Kaggle)#
Link: kaggle.com/datasets/terencicp/e-commerce-dataset-by-olist-as-an-sqlite-database
Real data from Olist, a Brazilian e-commerce marketplace - about 100,000 orders (2016-2018) with customers, sellers, products, payments, reviews and geolocation, imported into a single SQLite file olist.sqlite (~113 MB). The original CSV version is at kaggle.com/datasets/olistbr/brazilian-ecommerce.
Setup (10 minutes)#
- Download and unzip
olist.sqlitefrom the link above (free Kaggle account needed). - Install DB Browser for SQLite (free, Windows/Mac/Linux) → Open Database → choose
olist.sqlite. - Open the Database Structure tab - list the tables and note the key columns (order_id, customer_id, product_id, seller_id).
- Open the Execute SQL tab to write queries.
Large tables: always start with SELECT * FROM table LIMIT 10; to see the columns before writing big queries.
Write one query per task, save them in a file olist_analysis.sql, and note each answer:
- How many orders are there per
order_status? - How many orders per month (use the purchase timestamp)? Which month had the most?
- Top 10 product categories by total item price.
- Average delivery time in days (delivered date - purchase date) by customer state. Which states wait longest?
- Share of payments by payment type, and the average number of instalments for credit cards.
- Average review score by product category - which categories have the lowest scores (minimum 100 reviews)? Use HAVING.
- Top 10 sellers by revenue, with their number of orders and average review score (joins across 3-4 tables).
- Use a window function to rank categories by revenue within each year.
- Month-on-month order growth % with LAG.
- Write 5 insights for Olist management (finding + why it matters + action).
Column and table names in the Olist SQLite file may differ from the original CSV names (the uploader shortened them). Always check the Database Structure tab first.
Summary#
- Break business questions into small, verifiable SQL steps.
- State metric definitions (e.g. revenue = delivered orders after discount).
- Watch the grain after joins; verify numbers two ways.
- Practise on a real 100k-order database to become interview-ready.