Student starter code (30% baseline)
index.html- Main HTML pagescript.js- JavaScript logicstyles.css- Styling and layoutpackage.json- Dependenciessetup.sh- Setup scriptREADME.md- Instructions (below)💡 Download the ZIP, extract it, and follow the instructions below to get started!
Welcome to advanced SQL querying! This activity teaches you to work with multiple tables using JOINs, master filtering, and build complex e-commerce search queries.
By completing this activity, you will:
IMPORTANT: This template includes WORKING CODE! You can see results immediately:
Download SQLite Browser (if you don't have it):
Open the database files:
ecommerce.dbsqlite/schema.sql -> Click "Execute" ▶️sample-data.sql -> Click "Execute" ▶️Run the queries:
sqlite/queries.sqldocker-compose up -d
docker exec -it w4-mysql mysql -u root -plearning123 ecommerce_db
70% of the code is implemented for you:
Location: sqlite/queries.sql line 160
Your Task: Find orders meeting multiple complex criteria
Success Criteria:
Hints:
Why This Matters: Real e-commerce systems need complex filtering for reporting and analytics.
Location: sqlite/queries.sql line 185
Your Task: Count how many orders each customer has placed
Success Criteria:
Hints:
Expected Output: Customers with order counts ranging from 0-5 orders
Why This Matters: Customer analytics help identify your best customers for loyalty programs.
Location: sqlite/queries.sql line 215
Your Task: Find customers who have spent the most money
Success Criteria:
Hints:
Expected Output: Top 5 customers with total spending between $500-$1500
Why This Matters: Identifying VIP customers helps target marketing and retention efforts.
customers table (20 customers):
orders table (50 orders):
-- Basic JOIN
SELECT c.first_name, o.amount
FROM customers c
INNER JOIN orders o ON c.id = o.customer_id;
-- JOIN with filtering
SELECT c.first_name, COUNT(o.id) as order_count
FROM customers c
LEFT JOIN orders o ON c.id = o.customer_id
GROUP BY c.id;
-- Aggregate with conditions
SELECT c.first_name, SUM(o.amount) as total
FROM customers c
JOIN orders o ON c.id = o.customer_id
WHERE o.status = 'completed'
GROUP BY c.id
HAVING SUM(o.amount) > 500;
| Query | Expected Output |
|---|---|
| Query 1 | 20 customers |
| Query 2 | 50 orders |
| Query 3 | 50 customer-order combinations |
| Query 8 | 15-20 high-value completed orders |
| Query 9 | 20 customers with counts (0-5 each) |
| Query 10 | Top 5 customers, total $500-$1500 |
Your project is complete when:
You've mastered:
Next: Multi-table relationships with junction tables!
Ready to Submit? Complete this activity and submit through the Activity Submission Form
Happy querying! 🗄️✨