Get Category By Product Price
Great, we have obtained the quantity of products in each category. Now we need to retrieve the categories where the products cost more than a certain amount of money.
Just a reminder that we are working with two tables.
product
:
id | name | amount | price | category_id |
---|---|---|---|---|
1 | Shrimp | 50 | 450.00 | 1 |
2 | Salmon | 30 | 300.00 | 1 |
3 | Tuna | 40 | 350.00 | 1 |
4 | Rice | 100 | 200.00 | 2 |
... | ... | ... | ... | ... |
62 | Frozen Pie | 25 | 300.00 | 10 |
category
:
id | name | description |
---|---|---|
1 | Seafood | Products from the sea, including fish and shellfish. |
2 | Grains | Grain-based foods such as rice, wheat, and quinoa. |
3 | Vegetables | Fresh vegetables including leafy greens, roots, and tubers. |
4 | Fruits | Fresh fruits such as apples, bananas, and berries. |
... | ... | ... |
10 | Frozen Foods | Frozen products including meals, desserts, and vegetables. |
And now, let's move to the task:
Task
Your task is to retrieve the unique category names that have products with a price
higher than 450. Use the WHERE
clause for this, where you compare 450 with the value of the price
column.
Note
Please note that there should be only one column in the output -
category.name
. You do not include theprice
column in theSELECT
section; you only use it in theWHERE
section.
Good luck!
Everything was clear?
Course Content
Intermediate SQL
4. DDL and DML in SQL
Intermediate SQL
Get Category By Product Price
Great, we have obtained the quantity of products in each category. Now we need to retrieve the categories where the products cost more than a certain amount of money.
Just a reminder that we are working with two tables.
product
:
id | name | amount | price | category_id |
---|---|---|---|---|
1 | Shrimp | 50 | 450.00 | 1 |
2 | Salmon | 30 | 300.00 | 1 |
3 | Tuna | 40 | 350.00 | 1 |
4 | Rice | 100 | 200.00 | 2 |
... | ... | ... | ... | ... |
62 | Frozen Pie | 25 | 300.00 | 10 |
category
:
id | name | description |
---|---|---|
1 | Seafood | Products from the sea, including fish and shellfish. |
2 | Grains | Grain-based foods such as rice, wheat, and quinoa. |
3 | Vegetables | Fresh vegetables including leafy greens, roots, and tubers. |
4 | Fruits | Fresh fruits such as apples, bananas, and berries. |
... | ... | ... |
10 | Frozen Foods | Frozen products including meals, desserts, and vegetables. |
And now, let's move to the task:
Task
Your task is to retrieve the unique category names that have products with a price
higher than 450. Use the WHERE
clause for this, where you compare 450 with the value of the price
column.
Note
Please note that there should be only one column in the output -
category.name
. You do not include theprice
column in theSELECT
section; you only use it in theWHERE
section.
Good luck!
Everything was clear?