Grokking SQL for Tech Interviews
Vote
0% completed
16. Sellers With No Sales
Problem
Table: Customer
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| customer_id | int |
| customer_name | varchar |
+---------------+---------+
customer_id is the column with unique values for this table.
Each row of this table contains the information of each customer in the WebStore.
Table: Orders
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| order_id | int |
| sale_date | date |
| order_cost | int |
| customer_id | int |
| seller_id | int |
.....
.....
.....
Like the course? Get enrolled and start learning!
Christopher Guy Slater
· 5 days ago
-- the subquery serves as an anti-pattern, the outer query -- selects from any rows that don't fit the pattern. -- Similar pattern can be applied on `19. Ad-Free Sessions` for more practice SELECT s.seller_name FROM Seller s WHERE NOT EXISTS ( SELECT 1 FROM Orders o WHERE s.seller_id = o.seller_id AND o.sale_date BETWEEN '2020-01-01' AND '2020-12-31' ) ORDER BY s.seller_name ASC;
Reading Progress
0%