Отримати Мінімальну Ціну За Категорією
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 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.namecolumn and the minimum value of thepricecolumn from thecategorytable. - Assign the alias
category_nameto the first column andmin_priceto the second. - Join the
producttable on the common columncategory.id = product.category_id. - Group the data by
category.name. - Use a
HAVINGclause with the conditionCOUNT(product.name) > 5. - Sort the results by
category_name.
Рішення
Дякуємо за ваш відгук!
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
How should I organize the results for each category?
Can you provide an example of the product data format?
Do you want the minimum price for all categories or just specific ones?
Awesome!
Completion rate improved to 4
Отримати Мінімальну Ціну За Категорією
Свайпніть щоб показати меню
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 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.namecolumn and the minimum value of thepricecolumn from thecategorytable. - Assign the alias
category_nameto the first column andmin_priceto the second. - Join the
producttable on the common columncategory.id = product.category_id. - Group the data by
category.name. - Use a
HAVINGclause with the conditionCOUNT(product.name) > 5. - Sort the results by
category_name.
Рішення
Дякуємо за ваш відгук!
single