7 kyu
Filtering Films by Special Features in PostgreSQL: Part 1
559bornForThis
Description:
Write a PostgreSQL query that selects film_id
, the title
and special_features
columns from the film table in the DVD rental database, and returns only the films that have both "Trailers" and "Deleted Scenes" as their special feature. special_features
is the text[]
type. It represents a one-dimensional array of values, where each value is of the text data type.
Notes:
- for the sample tests, static dump of DVD Rental Sample Database is used, for the final solution - random tests.
- Note that this query should return films that have other special features in addition to "Trailers" and "Deleted Scenes".
- The result should be order by title alphabetically, if title is the same - then by film_id in asc order.
Schema:
film
table:
Column | Type | Modifiers
------------------+-----------+-----------
film_id | integer | not null
title | varchar | not null
description | text | not null
release_year | integer | not null
language_id | integer | not null
rental_duration | integer | not null
rental_rate | numeric | not null
length | integer | not null
replacement_cost | numeric | not null
rating | varchar | not null
last_update | timestamp | not null
special_features | text[] | not null
Desired Output
The desired output should look like this:
film_id | title | special_features |
--------+-----------------------------------+----------------------------------------|
32 | A Shawshank Redemption | {Trailers, Deleted Scenes} |
14 | Monty Python and the Holy Grail | {Deleted Scenes,Commentaries,Trailers} |
...
Databases
SQL
Similar Kata:
Stats:
Created | May 4, 2023 |
Published | May 4, 2023 |
Warriors Trained | 869 |
Total Skips | 84 |
Total Code Submissions | 1958 |
Total Times Completed | 559 |
SQL Completions | 559 |
Total Stars | 8 |
% of votes with a positive feedback rating | 95% of 68 |
Total "Very Satisfied" Votes | 61 |
Total "Somewhat Satisfied" Votes | 7 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 8 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |