Month 2 — SQL Querying Essentials
SQL syntax, filtering, grouping, and analysis queries for beginners.
1 lessonOffice & Data SkillsFree to enrol
Lessons
01
SQL Foundations for Analysts
Video: enrol to watchSQL is how analysts pull data out of a database rather than waiting for someone to send an export.
The shape of a query
SELECT column_a, column_b
FROM table_name
WHERE some_condition
ORDER BY column_a;
SELECT chooses columns, FROM chooses the table, WHERE filters rows, ORDER BY sorts the result.
A worked example
SELECT customer_name, total
FROM orders
WHERE total > 1000
ORDER BY total DESC;
That returns high-value orders, largest first. DESC sorts descending; the default is ascending.
Counting and summing
SELECT COUNT(*) AS orders, SUM(total) AS revenue
FROM orders
WHERE status = 'completed';
Aliases with AS give the output column a readable name.
Grouping
SELECT region, SUM(total) AS revenue
FROM orders
GROUP BY region
ORDER BY revenue DESC;
GROUP BY turns one summary row into one row per region.
Joining two tables
Data is usually split across tables. A join stitches them back together on a shared key:
SELECT o.id, c.customer_name, o.total
FROM orders o
JOIN customers c ON c.id = o.customer_id;
The short letters (o, c) are aliases that save typing the full table name.
Why this beats a spreadsheet export
The query is reproducible and reviewable, it runs against live data, and it does not fall over at a million rows.
Practice
Write a query returning each region, its number of completed orders, and its total revenue, sorted from highest revenue down.