πŸš€ Day 1 SQL Demo

Business Questions β†’ SQL Solutions

w3schools.com/sql/trysql.asp?filename=trysql_select_all

πŸ“‹ Available Tables (8 total)

Customers
91 records
Categories
8 records
Employees
10 records
OrderDetails
518 records
Orders
196 records
Products
77 records
Shippers
3 records
Suppliers
29 records
1
Your First Query
SELECT *
πŸ’Ό BUSINESS QUESTION
"Show me all our customers."
SELECT * FROM Customers;
πŸŽ“ KEY TAKEAWAY
The asterisk (*) means "everything." This is how you explore a table you've never seen before. 91 customers appear β€” you just pulled data from a database!
2
Pick What You Need
SELECT columns
πŸ’Ό BUSINESS QUESTION
"I just need customer names and their cities for a mailing list."
SELECT CustomerName, City FROM Customers;
πŸŽ“ KEY TAKEAWAY
You don't always need everything. Selecting specific columns is faster and cleaner β€” especially when tables have 50+ columns.
3
Filter Your Data
WHERE
πŸ’Ό BUSINESS QUESTION
"We're expanding in Germany. Who are our German customers?"
SELECT CustomerName, City FROM Customers WHERE Country = 'Germany';
πŸŽ“ KEY TAKEAWAY
WHERE filters rows. Only 11 German customers appear. Notice the single quotes around 'Germany' β€” text values need quotes.
πŸ§ͺ STUDENT CHALLENGE
Find all customers in the USA. (Give them 1 minute to try.)
4
Filter by Numbers
WHERE + comparison
πŸ’Ό BUSINESS QUESTION
"Which products cost more than $50? We need to review our premium pricing."
SELECT ProductName, Price FROM Products WHERE Price > 50;
πŸŽ“ KEY TAKEAWAY
Numbers don't need quotes. You can use > < >= <= = and <> (not equal). Only 7 premium products here.
πŸ§ͺ STUDENT CHALLENGE
Find products under $20. How many are there?
5
Sort Results
ORDER BY
πŸ’Ό BUSINESS QUESTION
"What are our most expensive products? Show me the top-priced items first."
SELECT ProductName, Price FROM Products ORDER BY Price DESC;
πŸŽ“ KEY TAKEAWAY
ORDER BY sorts results. DESC = descending (highest first), ASC = ascending (lowest first, this is the default). "CΓ΄te de Blaye" at $263.50 is the priciest!
6
Combine Conditions
AND / OR
πŸ’Ό BUSINESS QUESTION
"Find affordable beverages β€” drinks under $20."
SELECT ProductName, Price FROM Products WHERE CategoryID = 1 AND Price < 20;
πŸŽ“ KEY TAKEAWAY
AND means both conditions must be true. OR means either condition works. CategoryID 1 = Beverages (we'll learn JOINs later to see the actual category name).
7
Count Things
COUNT()
πŸ’Ό BUSINESS QUESTION
"How many orders did we process?"
SELECT COUNT(*) FROM Orders;
πŸŽ“ KEY TAKEAWAY
COUNT() is your first "aggregate function" β€” it summarizes data. Result: 196 orders. We'll learn more functions like SUM, AVG, MAX, MIN soon.
8
Sneak Peek: Connecting Tables
JOIN (preview)
πŸ’Ό BUSINESS QUESTION
"Show me orders with customer names β€” not just IDs."
SELECT Top 10 Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
πŸŽ“ KEY TAKEAWAY
This is a JOIN β€” connecting two tables through a shared column (CustomerID). This is where SQL gets powerful. We'll master this in Week 4. For now, just see that it's possible!
βœ“
What You Just Learned
SELECT -- Pick columns FROM -- Choose table WHERE -- Filter rows ORDER BY -- Sort results
🎯 KEY TAKEAWAY
You just asked a database 8 business questions and got instant answers. This is what data analysts do every day. By Week 5, you'll be writing queries twice this complex without thinking twice.