Table: actor
col_name | col_type -------------+-------------------------- actor_id | integer first_name | text last_name | text
Question 12
'EN' or 'RY'.Table: actor
col_name | col_type -------------+-------------------------- actor_id | integer first_name | text last_name | text
Sample results
last_name | count -----------+------- ALLEN | 3 BERGEN | 1
Solution
postgresSELECT
last_name,
COUNT(*)
FROM actor
WHERE last_name LIKE ('%RY')
OR last_name LIKE ('%EN')
GROUP BY last_name;
Explanation
This query is retrieving data from the "actor" table in the Postgres database. It is selecting the "last_name" column and the count of all rows for each distinct "last_name" value. The conditions in the "WHERE" clause are filtering the results to only include rows where the "last_name" ends with either "RY" or "EN". The "GROUP BY" clause is grouping the results by "last_name" so that the count is calculated for each unique "last_name" value. This query can be useful for analyzing the distribution of actors with certain last names in a 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.