Table: actor
col_name | col_type -------------+-------------------------- actor_id | integer first_name | text last_name | text
Question 11
Find the number of actors whose last name is one of the following:
'DAVIS', 'BRODY', 'ALLEN', 'BERRY'
Table: actor
col_name | col_type -------------+-------------------------- actor_id | integer first_name | text last_name | text
Sample results
last_name | count -----------+------- ALLEN | 3 DAVIS | 3
Solution
postgresSELECT
last_name,
COUNT(*)
FROM actor
WHERE last_name IN ('DAVIS', 'BRODY', 'ALLEN', 'BERRY')
GROUP BY last_name;
Explanation
This query is selecting data from the "actor" table in a Postgres database. It is selecting the "last_name" column and counting the number of occurrences of each last name for actors with the last names 'DAVIS', 'BRODY', 'ALLEN', or 'BERRY'. The "GROUP BY" clause is used to group the results by the last name column. This query is useful for analyzing the popularity or frequency of certain last names within the actors 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.