ALL and ANY operator in SQL
-- Creating the Products table
DROP TABLE IF EXISTS Products;
CREATE TABLE Products (
ProductID INT PRIMARY KEY,
ProductName NVARCHAR(50),
UnitPrice DECIMAL(18, 2),
CategoryID INT
);
-- Inserting data into the Products table
INSERT INTO Products (ProductID, ProductName, UnitPrice, CategoryID)
VALUES
(1, 'Laptop', 1500.00, 1),
(2, 'Mouse', 20.00, 1),
(3, 'Keyboard', 50.00, 1),
(4, 'Monitor', 300.00, 2),
(5, 'Desk', 200.00, 2),
(6, 'Chair', 100.00, 2),
(7, 'Pen', 2.00, 3),
(8, 'Notebook', 5.00, 3),
(9, 'Binder', 10.00, 3);
Question:
1. Find products in Category 1 (e.g., Electronics) that are more expensive than any product in Category 3 (e.g., Stationery).
2. Find products in Category 2 (e.g., Furniture) that are more expensive than all products in Category 3 (e.g., Stationery).
Comments
Post a Comment