Table 1: category
Movie categories.
col_name | col_type -------------+-------------------------- category_id | integer name | text
Question 37
Table 1: category
Movie categories.
col_name | col_type -------------+-------------------------- category_id | integer name | text
Table 2: film_category
A film can only belong to one category
col_name | col_type -------------+-------------------------- film_id | smallint category_id | smallint
Sample results
name -------- Category Name
Solution
postgresSELECT
C.name
FROM film_category FC
INNER JOIN category C
ON C.category_id = FC.category_id
GROUP BY C.name
ORDER BY COUNT(*) DESC
LIMIT 1;
Explanation
This query selects the name of the category that appears the most frequently in the film_category table. It does this by joining the film_category table with the category table on their category_id columns. Then, it groups the result by the name of the category and orders the groups by the count of rows in each group in descending order. Finally, it limits the result to only the first row, which will be the category with the highest count.
Last Submission
postgresNo submission yet for this engine. Run and submit your query to save it here.
Submit a query to compare against expected output.
Interview timer
Recommended interview pacing
Easy: 5 min for direct warm-up style questions.
Medium: 10 min for multi-step interview queries.
Hard: 15 min for layered questions with tighter time pressure.
A common bar is solving about 2 medium-or-harder questions in a 30 minute interview.
5:00
Run your query to preview results here.