Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

23:40 21/04/2024 Skill Assessment

Back to Results

Data Management in SQL (PostgreSQL)

Question 7

Advanced

Intermediate

Novice

1 2 3 4 5 6 7 8 9 10 11 12 13

There was an error in your code BETA

In your code, you forgot to include the JOIN condition between the bike_trips table and the bike table. Without specifying how
the two tables are related, the query will not be able to fetch the correct data. In the correct code, a LEFT JOIN is used along with
the ON clause to specify that the bike_ID from bike_trips should match the bike_ID from the bike table. This allows the query
to correctly retrieve the data from both tables based on the specified relationship.

Was the AI Assistant helpful?

Yes No

Join the bike_trips table with bike but keep all the records from bike_trips no matter whether they have a match in bike .

-- bike_trips
| trip_ID | duration | bike_ID |
|---------|----------|---------|
| 364 | 60 | 5000 |
| 365 | 900 | 2300 |
| 366 | 720 | 5002 |

-- bike
| bike_ID | last_date_in_use | color |
|---------|------------------|-------|
| 2300 | 2020-04-15 | blue |
| 2350 | 2020-04-15 | green |
| 3000 | 2020-04-18 | green |

Complete the code to return the output

SELECT Trip_ID, Duration, t.bike_ID, last_date_in_use, color


FROM bike_trips AS t
bike AS b
;
LEFT JOIN bike AS b
ON t.bike_ID = b.bike_ID;

Expected Output Your Output

syntax error at or near "{"


trip_id duration b i ke _ i d last_date_in_use colo LINE 3: {{option}} bike AS b
^
365 900 2300 2020-04-15 blue

364 60 5000

https://assessment-v2.datacamp.com/15e09043-62d9-4b3e-a10c-638c40a5ea4c/review?returnUrl=https%253A%252F%252Fapp.datacamp.com%252Fcertificat… 1/2
23:40 21/04/2024 Skill Assessment

trip_id duration b i ke _ i d last_date_in_use colo

366 720 5002

Incorrect answer

Difficulty MEDIUM

Skill Joining Multiple Datasets

Report Issue

https://assessment-v2.datacamp.com/15e09043-62d9-4b3e-a10c-638c40a5ea4c/review?returnUrl=https%253A%252F%252Fapp.datacamp.com%252Fcertificat… 2/2

You might also like