Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Get Product Amount By Category | Joining Tables
course content

Зміст курсу

Intermediate SQL

Get Product Amount By CategoryGet Product Amount By Category

Great job!

Now the company has a new task for us.

A new supplier contacted us and said that they can supply goods from the categories Meat or Grains cheaply. We need to find out which products in these categories have less than 100 units left in stock.

Just a reminder, 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.

Завдання

Your task is to retrieve the product names and their quantities in stock. To do this, you'll need to join two tables. The category of these products should be Meat or Grains. Keep in mind that you'll need to use the OR operator for this. Also, the quantity of the product should be less than 100. To do this, you'll need to use the AND operator.

Also, you need to sort the result by the name column using the ORDER BY clause.

Note

Keep in mind that you should wrap the string with the OR operation in parentheses and then use the AND operator. Here, the standard order of operations from discrete mathematics applies.

As a result, you should have 2 columns: product_name and amount, so don't forget to set appropriate aliases!

Все було зрозуміло?

Секція 3. Розділ 4
toggle bottom row
course content

Зміст курсу

Intermediate SQL

Get Product Amount By CategoryGet Product Amount By Category

Great job!

Now the company has a new task for us.

A new supplier contacted us and said that they can supply goods from the categories Meat or Grains cheaply. We need to find out which products in these categories have less than 100 units left in stock.

Just a reminder, 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.

Завдання

Your task is to retrieve the product names and their quantities in stock. To do this, you'll need to join two tables. The category of these products should be Meat or Grains. Keep in mind that you'll need to use the OR operator for this. Also, the quantity of the product should be less than 100. To do this, you'll need to use the AND operator.

Also, you need to sort the result by the name column using the ORDER BY clause.

Note

Keep in mind that you should wrap the string with the OR operation in parentheses and then use the AND operator. Here, the standard order of operations from discrete mathematics applies.

As a result, you should have 2 columns: product_name and amount, so don't forget to set appropriate aliases!

Все було зрозуміло?

Секція 3. Розділ 4
toggle bottom row
some-alt