
Products by Categories
Paulo R. Rodegheri Brazil
As usual the sales industry is doing an analysis of how many products we have in stock, and you can help them.
Then your job will display the name and amount of products of each category.
Schema
Column | Type |
id (PK) | numeric |
name | varchar |
amount | numeric |
price | numeric |
id_categories (FK) | numeric |
Column | Type |
id (PK) | numeric |
name | varchar |
Tables
id | name | amount | price | id_categories |
1 | Two-doors wardrobe | 100 | 800 | 1 |
2 | Dining table | 1000 | 560 | 3 |
3 | Towel holder | 10000 | 25.50 | 4 |
4 | Computer desk | 350 | 320.50 | 2 |
5 | Chair | 3000 | 210.64 | 4 |
6 | Single bed | 750 | 460 | 1 |
id | name |
1 | wood |
2 | luxury |
3 | vintage |
4 | modern |
5 | super luxury |
Output Sample
name | sum |
luxury | 350 |
modern | 13000 |
wood | 850 |
vintage | 1000 |
N.B.: It's better if you solve this by your own. Thank you!
URI - BEECROWD Online Judge 2609 Solve in SQL:
-- Solved by IntesarSELECT c.name, sum(amount)FROM categories c, products pWHERE c.id = p.id_categoriesgroup by c.name;
0 Comments