Instruction
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
Expected results
Solution postgres
SELECT
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.
Copied
Your results