Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Challenge: Get Minimum Price By Category | Joining Tables
Intermediate SQL
course content

Cursusinhoud

Intermediate SQL

Intermediate SQL

1. Grouping
2. Nested Subqueries
3. Joining Tables
4. DDL and DML in SQL

book
Challenge: Get Minimum Price By Category

The company needs to find the minimum price of a product from each category in order to organize a marketing campaign. They have assigned you this task!

Taak

Swipe to start coding

Your task is to obtain the minimum price for each product category. However, to provide customers with options, you need to retrieve only those categories where there are more than 5 different products.

Join two tables, aggregate the data, and use the HAVING clause. At the end, sort the result by the category_name in the ascending order.

Pay attention that in the response, you should have 2 columns: category_name and min_price. So don't forget to set aliases for these columns!

Brief Instructions

  • Retrieve the category.name column and the minimum value of the price column from the category table.
  • Assign the alias category_name to the first column and min_price to the second.
  • Join the product table on the common column category.id = product.category_id.
  • Group the data by category.name.
  • Use a HAVING clause with the condition COUNT(product.name) > 5.
  • Sort the results by category_name.

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 3
toggle bottom row

book
Challenge: Get Minimum Price By Category

The company needs to find the minimum price of a product from each category in order to organize a marketing campaign. They have assigned you this task!

Taak

Swipe to start coding

Your task is to obtain the minimum price for each product category. However, to provide customers with options, you need to retrieve only those categories where there are more than 5 different products.

Join two tables, aggregate the data, and use the HAVING clause. At the end, sort the result by the category_name in the ascending order.

Pay attention that in the response, you should have 2 columns: category_name and min_price. So don't forget to set aliases for these columns!

Brief Instructions

  • Retrieve the category.name column and the minimum value of the price column from the category table.
  • Assign the alias category_name to the first column and min_price to the second.
  • Join the product table on the common column category.id = product.category_id.
  • Group the data by category.name.
  • Use a HAVING clause with the condition COUNT(product.name) > 5.
  • Sort the results by category_name.

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 3
Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Onze excuses dat er iets mis is gegaan. Wat is er gebeurd?
some-alt