For this challenge you need to create a SELECT statement, this SELECT statement will use an IN to check whether a department has had a sale with a price over 98.00 dollars.
departments table schema
- id
- name
sales table schema
- id
- department_id (department foreign key)
- name
- price
- card_name
- card_number
- transaction_date
resultant table schema
- id
- name
Solution:
SELECT
id, name
FROM
departments
WHERE
id IN (
SELECT department_id FROM sales WHERE price > 98.00
)
Result:
| id | name |
| 1 | Shoes |
| 4 | Tools |
| 5 | Home |
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
| Best-Selling Books (SQL for Beginners #5) (0) | 2022.06.19 |
|---|---|
| SQL Basics: Simple table totaling. (0) | 2022.06.18 |
| Easy SQL: Absolute Value and Log to Base (0) | 2022.06.16 |
| SQL Basics: Create a FUNCTION (0) | 2022.06.15 |
| SQL with Street Fighter: Total Wins (0) | 2022.06.14 |