Table 1: actor
col_name | col_type -------------+-------------------------- actor_id | integer first_name | text last_name | text
Question 46
customers and actors whose last name starts with letter 'A'.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
first_name | last_name ------------+----------- KENT | ARSENAULT JOSE | ANDREW
Solution
postgresSELECT first_name, last_name
FROM customer
WHERE last_name LIKE 'A%'
UNION
SELECT first_name, last_name
FROM actor
WHERE last_name LIKE 'A%';
Explanation
This query is selecting the first name and last name columns from two different tables, "customer" and "actor". It uses the "WHERE" clause to filter the results and only show rows where the last name starts with the letter "A".
The "UNION" operator is used to combine the results of both selects into a single result set, eliminating any duplicates in the process.
Overall, this query is retrieving the first and last names of all customers and actors whose last name starts with the letter "A".
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.