Table: film_category
A film can only belong to one category
col_name | col_type -------------+-------------------------- film_id | smallint category_id | smallint
Question 18
Table: film_category
A film can only belong to one category
col_name | col_type -------------+-------------------------- film_id | smallint category_id | smallint
Sample results
category_id | film_cnt
------------+----------
1 | 2
Solution
postgresSELECT
category_id,
COUNT(*) film_cnt
FROM film_category
GROUP BY category_id
ORDER BY film_cnt DESC
LIMIT 1;
Explanation
This query is selecting the category_id column and counting the number of films in each category by grouping the results by category_id using the film_category table. The results will be ordered in descending order by the film count (film_cnt) and only the top result will be returned due to the LIMIT 1 clause. This query is useful for finding the category with the most films in the database.
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.