URI Online Judge Solution 2623 Categories with Various Products Using PostgreSQL Query Language.The sales industry needs a report to know what products are left in stock.
To help the sales industry, display the product name and category name for products whose amount is greater than 100 and the category ID is 1,2,3,6 or 9. Show the results in ascendent order by category ID.
Schema
productsColumn | Type |
id (PK) | numeric |
name | character varying (255) |
amount | numeric |
price | numeric |
id_categories (FK) | numeric |
categoriesColumn | Type |
id (PK) | numeric |
name | character varying (255) |
Tables
productsid | name | amount | price | id_categories |
1 | Blue Chair | 30 | 300.00 | 9 |
2 | Red Chair | 200 | 2150.00 | 2 |
3 | Disney Wardrobe | 400 | 829.50 | 4 |
4 | Blue Toaster | 20 | 9.90 | 3 |
5 | Solar Panel | 30 | 3000.25 | 4 |
categoriesid | name |
1 | Superior |
2 | Super Luxury |
3 | Modern |
4 | Nerd |
5 | Infantile |
6 | Robust |
9 | Wood |
Output Sample
name | name |
Red Chair | Super Luxury |
URI 2623 Solution in SQL:
SELECT products.name, categories.name
FROM products
INNER JOIN categories
ON products.id_categories = categories.id
WHERE products.amount > 100
AND products.id_categories IN (1,2,3,6,9)
Comments
Post a Comment