Advanced: Novice

You might also like

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

23:37 21/04/2024 Skill Assessment

Back to Results

Data Management in SQL (PostgreSQL)

Question 3

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 used UNION which removes duplicate rows from the result set. This is why you are only seeing [object Object]
as the output. To include all rows from both movie_2000 and movie_2010 tables, you should use UNION ALL instead of UNION. This
will include all rows from both tables in the result set.

Was the AI Assistant helpful?

Yes No

Add the rows from the movie_2010 table to movie_2000 but keep the duplicates.

-- movie_2000
| year | title | budget |
|---------|--------------------------|--------------|
| 2000 | Mission: Impossible 2 | 125000000 |
| 2004 | Shrek 2 | 150000000 |
| 2008 | The Dark Knight | 185000000 |
| 2010 | Toy Story 3 | 200000000 |

-- movie_2010
| year | title | budget |
|---------|------------------------------------|----------------|
| 2010 | Toy Story 3 | 200000000 |
| 2014 | Transformers: Age of Extinction | 210000000 |
| 2015 | Star Wars: The Force Awakens | 245000000 |
| 2016 | Captain America: Civil War | 250000000 |

Complete the code to return the output

SELECT *
FROM movie_2000
UNION
UNION ALL
SELECT *
FROM movie_2010
ORDER BY year;

Expected Output Your Output

year title budget year title budget

2000 Mission: Impossible 2 125000000 2000 Mission: Impossible 2 125000000

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

year title budget year title budget

2004 Shrek 2 150000000 2004 Shrek 2 150000000

2008 The Dark Knight 185000000 2008 The Dark Knight 185000000

2010 Toy Story 3 200000000 2010 Toy Story 3 200000000

2010 Toy Story 3 200000000 2014 Transformers: Age of Extinction 210000000

2014 Transformers: Age of Extinction 210000000 2015 Star Wars: The Force Awakens 245000000

2015 Star Wars: The Force Awakens 245000000 2016 Captain America: Civil War 250000000

2016 Captain America: Civil War 250000000

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