Section 1 · Lesson 1
Your first query: SELECT and FROM
Read columns from a table, rename them, and preview data safely with LIMIT.
Every SQL query answers a question about data that lives in tables: rows of records, each with the same named columns. In this course you’ll work with a fictional ad-tech company’s database: advertisers run campaigns, campaigns generate daily performance stats, and customers place orders.
The shape of a query
SELECT name, channel -- which columns you want
FROM campaigns; -- which table they come from
SELECTlists the columns to return, separated by commas.SELECT *returns all of them.FROMnames the table.- The semicolon ends the statement. SQL keywords aren’t case-sensitive, but writing them in UPPERCASE makes queries easier to scan.
Renaming columns with AS
Column names in the result can be changed with an alias. This doesn’t modify the table; it only labels the output, which matters when you share results or build reports.
SELECT name AS campaign_name, daily_budget AS budget_usd
FROM campaigns;
Previewing with LIMIT
Real tables can have millions of rows. Before running anything heavy, peek at a few rows:
SELECT * FROM daily_stats LIMIT 10;
Without an ORDER BY (next lessons), the database returns rows in whatever order is
cheapest, so LIMIT alone gives you a sample, not the “top” rows.
Explore the dataset
Use the Tables panel in the sandbox to see every table and its columns. Try these in the sandbox before the tasks:
SELECT * FROM campaigns LIMIT 5;
SELECT first_name, last_name, country FROM customers LIMIT 5;
Tip: Selecting only the columns you need is faster and makes results easier to read. Professionals avoid
SELECT *in production queries.
Practice
Write your answer, press Run to see results and Check answer to grade it. Shortcuts: Ctrl/⌘ + Enter run, Shift + Enter check.
Meet the advertisers
DoneReturn every column for every row in the advertisers table.
Need a hint?
*means all columns.- The pattern is
SELECT ... FROM table_name;
Practice tasks, quizzes and the certificate are part of the course. The first lesson is free to try.
-- Write your query below
Tables in this database
advertisers (12 rows)campaigns (40 rows)daily_stats (1,561 rows)customers (300 rows)orders (900 rows)ab_test (4,000 rows)Pick specific columns
DoneList each campaign's name, channel and daily_budget, in that column order.
Need a hint?
- Separate column names with commas.
Practice tasks, quizzes and the certificate are part of the course. The first lesson is free to try.
SELECT name
FROM campaigns;
Tables in this database
advertisers (12 rows)campaigns (40 rows)daily_stats (1,561 rows)customers (300 rows)orders (900 rows)ab_test (4,000 rows)Rename and preview
DoneShow the first 5 rows of daily_stats with two columns: date, and spend renamed to spend_usd. Keep the table's natural order (no sorting needed).
Need a hint?
ASgives a column a new name in the result.LIMIT 5returns at most five rows.
Practice tasks, quizzes and the certificate are part of the course. The first lesson is free to try.
SELECT date, spend
FROM daily_stats;
Tables in this database
advertisers (12 rows)campaigns (40 rows)daily_stats (1,561 rows)customers (300 rows)orders (900 rows)ab_test (4,000 rows)