Skip to main content

URI Problem 2623 Solution Categories with Various Products - URI Online Judge Solution

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

products
ColumnType
id (PK)numeric
namecharacter varying (255)
amountnumeric
pricenumeric
id_categories (FK)numeric
 
categories
ColumnType
id (PK)numeric
namecharacter varying (255)

Tables

products
idnameamountpriceid_categories
1Blue Chair30300.009
2Red Chair2002150.002
3Disney Wardrobe400829.504
4Blue Toaster209.903
5Solar Panel303000.254
 
categories
idname
1Superior
2Super Luxury
3Modern
4Nerd
5Infantile
6Robust
9Wood

Output Sample

namename
Red ChairSuper 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