Module 1 — SQL Basics & SELECT Statement
01
Module 1 · Foundations

SQL Basics &
the SELECT Statement

Before you can filter, group, or aggregate anything, you need to be fluent in the one question every data analyst asks a thousand times a day: “show me this.”

■ Learning Objectives

  • Understand the basic structure of the SQL SELECT statement
  • Learn how to retrieve all columns, and specific columns
  • Create your first database and table
  • Insert sample data for practice

■ Concept Explanation

The SELECT statement is the foundation of SQL. It’s used to query and retrieve data from databases. The basic syntax is: SELECT (which columns) FROM (which table). Think of it as asking the database: “Show me this column from this table.”

Why this matters for Data Analytics — analysts spend most of their time extracting and exploring data. SELECT is your primary tool for that. Master it before moving on to filtering, grouping, and aggregating.

Setup

Create the Sample Database & Table

Every module in this course works against the same practice ground: a small employees table you’ll query from every angle.

Step 1 — Database
CREATE DATABASE IF NOT EXISTS analytics_db;
USE analytics_db;
Step 2 — Table
CREATE TABLE IF NOT EXISTS employees (
    employee_id   INT PRIMARY KEY AUTO_INCREMENT,
    first_name    VARCHAR(50) NOT NULL,
    last_name     VARCHAR(50) NOT NULL,
    department    VARCHAR(50),
    position      VARCHAR(50),
    salary        DECIMAL(10, 2),
    hire_date     DATE,
    email         VARCHAR(100)
);
Step 3 — Sample Data
INSERT INTO employees
    (first_name, last_name, department, position, salary, hire_date, email)
VALUES
    ('Raj', 'Kumar', 'Sales', 'Sales Executive', 45000.00, '2020-01-15', 'raj.kumar@company.com'),
    ('Priya', 'Sharma', 'IT', 'Senior Developer', 75000.00, '2019-03-22', 'priya.sharma@company.com'),
    ('Amit', 'Patel', 'Finance', 'Financial Analyst', 60000.00, '2021-05-10', 'amit.patel@company.com'),
    ('Sneha', 'Singh', 'IT', 'Junior Developer', 50000.00, '2022-07-01', 'sneha.singh@company.com'),
    ('Vikram', 'Reddy', 'Sales', 'Sales Manager', 65000.00, '2018-11-30', 'vikram.reddy@company.com'),
    ('Anjali', 'Gupta', 'HR', 'HR Manager', 62000.00, '2020-02-14', 'anjali.gupta@company.com'),
    ('Rohit', 'Verma', 'Finance', 'Finance Manager', 70000.00, '2019-09-05', 'rohit.verma@company.com'),
    ('Kavya', 'Nair', 'Marketing', 'Marketing Executive', 48000.00, '2021-10-20', 'kavya.nair@company.com'),
    ('Nikhil', 'Desai', 'IT', 'Data Analyst', 55000.00, '2022-01-12', 'nikhil.desai@company.com'),
    ('Divya', 'Pandey', 'Sales', 'Sales Executive', 44000.00, '2022-03-08', 'divya.pandey@company.com');
• • •
01

1Select ALL Columns

Query
SELECT * FROM employees;
?The * (asterisk) means “all columns.” This query retrieves every column and all rows from the employees table.
02

2Select Specific Columns

Query
SELECT first_name, last_name, department, salary FROM employees;
?Instead of *, we name exactly which columns to display. This is more efficient and gives cleaner results.
03

3Columns with Aliases

Query
SELECT first_name AS 'First Name',
       last_name AS 'Last Name',
       department AS 'Department',
       salary AS 'Annual Salary'
FROM employees;
?The AS keyword creates temporary column names for readability — useful for reports and presentations. The underlying table is never changed.
• • •

Practice Questions

Test Yourself
✎ Question 1

Write a query to display only the email addresses of all employees.

Reveal Answer Key
SELECT email FROM employees;
✎ Question 2

Write a query to show employee names and their departments only.

Reveal Answer Key
SELECT first_name, last_name, department
FROM employees;
✎ Question 3

Write a query to display position and salary, but rename salary as ‘Monthly_Salary’.

Reveal Answer Key
SELECT position, salary AS 'Monthly_Salary'
FROM employees;
✎ Question 4

Write a query that shows hire_date and first_name with aliases ‘Joining Date’ and ‘Employee Name’.

Reveal Answer Key
SELECT hire_date AS 'Joining Date',
       first_name AS 'Employee Name'
FROM employees;
Module 1 · SQL Basics & SELECT Statement · analytics_db.employees

Leave a Comment