0% found this document useful (0 votes)
11 views3 pages

SQL Basics: SELECT Queries Guide

Session 1 of the SQL for Data Analysis course introduces SQL and its application in data analysis, focusing on writing basic SELECT queries. Students will learn to navigate relational databases, apply filtering and aliasing, and complete hands-on exercises. The session includes a quiz and assignments to reinforce learning objectives.

Uploaded by

samiursami71
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

SQL Basics: SELECT Queries Guide

Session 1 of the SQL for Data Analysis course introduces SQL and its application in data analysis, focusing on writing basic SELECT queries. Students will learn to navigate relational databases, apply filtering and aliasing, and complete hands-on exercises. The session includes a quiz and assignments to reinforce learning objectives.

Uploaded by

samiursami71
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQL for Data Analysis - Session 1 Instructor Guide

Session 1: Introduction to SQL & SELECT Queries

Learning Objectives:

By the end of this session, students will be able to:

• Understand what SQL is and how it's used in data analysis


• Navigate a relational database schema
• Write basic SELECT queries
• Apply filtering and aliasing in queries

1. Concepts & Definitions

What is SQL?

• SQL (Structured Query Language) is used to manage and query relational databases.
• SQL is case-insensitive (but capitalization improves readability).

Relational Database Concepts:

• Tables: like spreadsheets (rows = records, columns = fields)


• Primary Key: unique identifier for each row (e.g., customer_id)
• Foreign Key: connects one table to another (e.g., orders.customer_id)

2. Sample Schema for Practice


• customers: customer_id, name, email, signup_date
• orders: order_id, customer_id, order_date, total_amount
• products: product_id, name, category, price
• order_items: order_id, product_id, quantity

✏ 3. SQL Syntax Basics

-- Basic Query
SELECT * FROM customers;

1
-- Select specific columns
SELECT name, email FROM customers;

-- Add aliasing
SELECT name AS customer_name, email AS contact_email FROM customers;

-- Filter data
SELECT * FROM orders WHERE total_amount > 100;

-- Use multiple filters


SELECT * FROM orders
WHERE total_amount > 100 AND order_date >= '2024-01-01';

4. Hands-On Exercises (in SQL Editor)

Exercise 1: Basic SELECT

-- Show all columns from the products table


SELECT * FROM products;

Exercise 2: Column Selection + Filtering

-- Show product name and price where price > 500


SELECT name, price FROM products
WHERE price > 500;

Exercise 3: Add Aliases

-- List order_id and total_amount, alias as 'amount'


SELECT order_id, total_amount AS amount
FROM orders;

🎓 5. Assignment (Homework)

1. Show only the names and emails of customers who signed up in 2023.
2. Retrieve all products from the 'Electronics' category with price below \$1000.
3. Find all orders above \$250 placed in January 2024.
4. Show only product name and price, alias price as "Unit Price"

2
🏋 6. Quiz Questions (Session 1)

Q1: What SQL keyword is used to retrieve data? A) GET B) SELECT C) SHOW D) QUERY Answer: B

Q2: Which clause filters rows based on condition? A) FROM B) ORDER BY C) WHERE D) GROUP BY Answer:
C

Q3: Which symbol is used for single-line comments in SQL? A) // B) -- C) ## D) /* */ Answer: B

Q4: True or False: SQL is case-sensitive. Answer: False

7. Files To Prepare for Students


• SQL Script File: session1_select_queries.sql
• PDF: "Session 1 Cheat Sheet - SELECT, WHERE, ALIAS"
• CSVs for mock database tables:
• [Link]
• [Link]
• [Link]
• order_items.csv

Let me know when you'd like:

• Session 2 (Filtering, Sorting, Aliasing)


• Downloadable slide deck
• SQL editor setup instructions for students (DBeaver, pgAdmin, or browser-based)

You might also like