Lesson 1.1

SELECT: choose your columns

Get exactly the columns you need from a table.

Imagine you're a data analyst at Netflix. The titles table has one row per movie or series.

1See everything in a table

SELECT * returns every column. FROM says which table to read.

SELECT *
FROM titles;

Practice

Show every column and every row of the titles table.

Write your query here

2Pick the columns you need

List the columns after SELECT, separated by commas. They come back in the order you write them.

SELECT title, type, release_year
FROM titles;

Practice

Show each title's name, country and the date it was added to Netflix.

Return: title, country and date added

Write your query here

3Rename a column with AS

AS gives a column a new name in your result. The table itself doesn't change.

SELECT title AS show_name, release_year AS year
FROM titles;

Practice

Show each title and its maturity rating, with the rating column named rating.

Return: title, rating

Write your query here

4Calculate a new column

You can do math on columns right in SELECT. Divide by 60.0, not 60, so you keep the decimals.

SELECT title, duration_min, duration_min / 60.0 AS duration_hours
FROM titles;

Common mistake

duration_min / 60 divides two whole numbers, so SQL drops the decimals: 90 / 60 gives 1, not 1.5.

Practice

How old is each title in 2026? Subtract release_year from 2026.

Return: title and age in years

Write your query here

5Remove repeats with DISTINCT

SELECT DISTINCT keeps one copy of each different row. With several columns, it keeps each different combination.

SELECT DISTINCT type
FROM titles;

Practice

List every country that has at least one title, each country once.

Return: country

Write your query here