Contenido del Curso
SQL Intermedio
SQL Intermedio
Obtener Precio Mínimo Por Categoría
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!
Swipe to show code editor
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 theprice
column from thecategory
table. - Assign the alias
category_name
to the first column andmin_price
to the second. - Join the
product
table on the common columncategory.id = product.category_id
. - Group the data by
category.name
. - Use a
HAVING
clause with the conditionCOUNT(product.name) > 5
. - Sort the results by
category_name
.
¡Gracias por tus comentarios!
Obtener Precio Mínimo Por Categoría
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!
Swipe to show code editor
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 theprice
column from thecategory
table. - Assign the alias
category_name
to the first column andmin_price
to the second. - Join the
product
table on the common columncategory.id = product.category_id
. - Group the data by
category.name
. - Use a
HAVING
clause with the conditionCOUNT(product.name) > 5
. - Sort the results by
category_name
.
¡Gracias por tus comentarios!