Table 1: actor
col_name | col_type -------------+-------------------------- actor_id | integer first_name | text last_name | text
Question 47
actor_id, customer: customer_id), first_name and last_name.Table 1: actor
col_name | col_type -------------+-------------------------- actor_id | integer first_name | text last_name | text
Table 2: customer
col_name | col_type -------------+-------------------------- customer_id | integer store_id | smallint first_name | text last_name | text email | text address_id | smallint activebool | boolean create_date | date active | integer
Sample results
customer_id | first_name | last_name
-------------+------------+--------------
55 | DORIS | REED
65 | ROSE | HOWARD
Solution
postgresSELECT customer_id, first_name, last_name
FROM customer
WHERE first_name LIKE '%D'
UNION
SELECT actor_id, first_name, last_name
FROM actor
WHERE first_name LIKE '%D';
Explanation
This query is selecting customer_id, first_name, and last_name from the "customer" table where the first name ends with the letter 'D'. It then combines this with the actor_id, first_name, and last_name from the "actor" table where the first name also ends with the letter 'D'. The UNION keyword is used to merge the results of both SELECT statements into a single table. This query can be used to find all customers and actors whose first name ends with the letter 'D'.
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.