Simplified
Simplified

Filter the videos

YOU
Lab 2

Filter the videos

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

Write the condition for each question, and get back exactly the videos that pass it.

Scenario

Simplified's team is checking its videos before it records more. Each question it asks is one query, and you write it.

Time
About 10 min
Steps
7
Where
Your browser

What this lab tests

  • 3.3 Comparing Values: Greater than and less than, Greater than or equal to, Not equal to
  • 3.4 Combining Conditions: When both must be true, Asking for a range, When either will do, Matching a list of values

Simplified keeps its videos in a table called videos, with each one's chapter and its length in seconds.

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

Can you write the condition for each question the team asks?

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

PostgreSQLStarting in your browser…
1

Step 1: Longer than 110 seconds

First, the team wants its longer videos.

Send back the title and seconds of every video longer than 110 seconds.

TestsGreater than and less than3.3 Comparing Values
SQLYour query
Connecting…
1
2
3
⌘ / Ctrl Enter to run
2

Step 2: 95 seconds or less

Now the team wants the short ones: every video of 95 seconds or less.

Send back their title and seconds.

TestsGreater than or equal to3.3 Comparing Values
Pass step 1 to open this one.
3

Step 3: Every chapter but the third

Chapter 3 was recorded last week, so the team checks the others first.

Send back the title of every video that isn't in chapter 3.

TestsNot equal to3.3 Comparing Values
Pass step 2 to open this one.
4

Step 4: Chapter 1, under 130 seconds

The team wants the videos of chapter 1 that run for less than 130 seconds.

Send back their title.

TestsWhen both must be true3.4 Combining Conditions
Pass step 3 to open this one.
5

Step 5: From 100 to 120 seconds

Send back the title and seconds of every video from 100 to 120 seconds, both ends included.

Write the range the short way.

TestsAsking for a range3.4 Combining Conditions
Pass step 4 to open this one.
6

Step 6: Fix the assistant's query

The team wants every video in chapter 2, and also any video of exactly 150 seconds.

An assistant wrote this query for it.

Predict what it sends back, run it, then fix it.

TestsWhen both must be true3.4 Combining ConditionsWhen either will do3.4 Combining Conditions
Pass step 5 to open this one.
7

Step 7: Three videos by title

The team records three videos again: Servers, Queries and results and Generated ids.

Send back their title and seconds, using one list of titles.

TestsMatching a list of values3.4 Combining Conditions
Pass step 6 to open this one.

Not yet: a video right on the number is missing, or shouldn't be there

> and < leave the number itself out.

>= and <= let it pass.

syntax error at or near ","

BETWEEN takes AND between its two numbers, not a comma: BETWEEN 100 AND 120.

column "servers" does not exist

Each title in the list is text, so each goes in its own single quotes.

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 7 steps done
Assistant

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