Simplified
Simplified

Find a video

YOU
Lab 1

Find a video

Write each query here, and run it on a real Postgres database in your browser.

Write the queries Simplified's server sends for its videos, and get back exactly the rows it needs.

Scenario

Simplified keeps every video you watch in a table called videos. You write the query its server sends each time it needs one.

Time
About 8 min
Steps
6
Where
Your browser

What this lab tests

  • 3.1 Picking Columns: Asking for certain columns, Asking for every column
  • 3.2 Picking Rows: Finding one row among millions, Why text needs quotes, When no row passes

Simplified keeps its videos in a Postgres table called videos, one row for each video.

videosidtitlechapterseconds1Servers11402Memory and disk1953Queries and results11204The primary key21105Generated ids2956The schema2807Text in quotes31508The empty result3100

Can you write the queries Simplified's server sends to it?

Each step runs your query on this table, in real Postgres.

PostgreSQLStarting in your browser…
1

Step 1: Every video's title and length

Simplified's team wants a list of every video, with how long it runs.

Send back each video's title and seconds.

TestsAsking for certain columns3.1 Picking Columns
SQLYour query
Connecting…
1
2
3
⌘ / Ctrl Enter to run
2

Step 2: A learner opens The schema

A learner opens a video called The schema.

Find its row by title, and send back its chapter and seconds.

TestsFinding one row among millions3.2 Picking RowsWhy text needs quotes3.2 Picking Rows
Pass step 1 to open this one.
3

Step 3: Videos of 95 seconds

Send back the title of every video that runs for exactly 95 seconds.

Two rows should come back.

TestsFinding one row among millions3.2 Picking Rows
Pass step 2 to open this one.
4

Step 4: Everything about video 4

Send back every column of the row whose id is 4.

TestsAsking for every column3.1 Picking ColumnsFinding one row among millions3.2 Picking Rows
Pass step 3 to open this one.
5

Step 5: Fix the assistant's query

An assistant wrote this query, to find how long Servers runs.

Run it, read the error, then fix it.

TestsWhy text needs quotes3.2 Picking Rows
Pass step 4 to open this one.
6

Step 6: A video that isn't there

Say Simplified's server looks for a video called Joins, which hasn't been made yet.

Predict what comes back, then send back that video's title and seconds.

TestsWhen no row passes3.2 Picking Rows
Pass step 5 to open this one.

unterminated quoted string

A quote is missing.

Text goes between two single quotes, like 'Servers'.

column "Servers" does not exist, after writing "Servers"

Text goes in single quotes, never double quotes.

So write 'Servers', not "Servers".

relation "vidoes" does not exist

Postgres can't find a table with that name.

Check the name after FROM: videos.

syntax error at or near "FROM"

Look just before FROM.

A comma after the last column, like title, seconds, FROM, is one too many.

Not yet: your columns aren't the ones the step needs

Name exactly the columns the step asks for, in its order, between SELECT and FROM.

Finish the lab

Each step passes once its query sends back the right rows. Then mark the lab complete to unlock the next lesson.

0 of 6 steps done
Assistant

Highlight lesson text and click Ask AI, or type a question below.