Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Obter Preço Mínimo Por Categoria | Juntando Tabelas
SQL Intermediário
course content

Conteúdo do Curso

SQL Intermediário

SQL Intermediário

1. Agrupamento
2. Subconsultas Aninhadas
3. Juntando Tabelas
4. DDL e DML em SQL

book
Obter Preço Mínimo Por Categoria

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!

Tarefa
test

Swipe to begin your solution

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.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 3
toggle bottom row

book
Obter Preço Mínimo Por Categoria

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!

Tarefa
test

Swipe to begin your solution

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.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 3
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt