Table 1: actor_movie
Actors who appeared in a movie.
col_name | col_type ------------+------------------- actor_id | integer first_name | character varying last_name | character varying
Question 51
Table 1: actor_movie
Actors who appeared in a movie.
col_name | col_type ------------+------------------- actor_id | integer first_name | character varying last_name | character varying
Table 2: actor_tv
Actors who appeared in a TV show.
col_name | col_type ------------+------------------- actor_id | integer first_name | character varying last_name | character varying
Sample results
first_name | last_name -------------+------------- ED | CHASE ZERO | CAGE CUBA | OLIVIER
Solution
postgresSELECT M.first_name, M.last_name
FROM actor_movie M
LEFT JOIN actor_tv T
ON M.actor_id = T.actor_id
WHERE T.actor_id IS NULL;
Explanation
This PostgreSQL query selects the first and last names of actors who have only appeared in movies but not in TV shows. It does this by joining two tables, actor_movie and actor_tv, on their actor_id columns. The LEFT JOIN keyword is used to include all rows from the actor_movie table and only matching rows from the actor_tv table. The WHERE clause filters out any rows where the actor_id in the actor_tv table is null, indicating that the actor has not appeared in any TV shows.
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.