Assignment 4
Assignment 4
Answers
1) Insert a record into Salesman table:
UPDATE Product SET Price = 50 WHERE PDesc = 'Trouser' AND Category = 'Apparel';
8) Display Product Id, Product Description and Category for 'electronics' products (case-
insensitive):
11) Display Product Id, Category, Price, Discount in descending order of Category and
ascending order of Price:
SELECT ProdId, Category, Price, Discount FROM Product ORDER BY Category DESC, Price
ASC;
12) Display Product Id, Category, and Discount for 'Sports' or 'Apparel' categories in
ascending order of Category and Discount:
SELECT ProdId, Category, Discount FROM Product WHERE Category IN ('Sports', 'Apparel')
ORDER BY Category ASC, Discount ASC;
16) Display Designation and Minimum Salary for those with no bonus and salary < 40000:
17) Display department and designation-wise maximum salary in range 35000 to 75000:
(SELECT SID, SName, Location FROM Salesman WHERE SName LIKE '%e%' AND Location
LIKE '%o%')
UNION ALL
(SELECT SID, SName, Location FROM Salesman WHERE SName LIKE '%a%' AND Location
LIKE '%a%');
19) Display Product details with discount < 10 or category 'Sports' (without duplicates):
SELECT DISTINCT ProdId, PDesc, Category, Discount FROM Product WHERE Discount < 10
OR Category = 'Sports';
20) Use INNER JOIN to display employee and computer details for 2013:
22) Display computer and employee details with 'Not assigned' for unallocated computers
(Outer Join):
SELECT COMPID, MAKE, MODEL, COALESCE(ENAME, 'Not assigned') FROM Computer LEFT
JOIN Employee ON Computer.COMPID = Employee.COMPID;
23) Display sale id and sale date for sales made by London salesmen:
24) Display employee and computer details, showing unassigned ones as NULL:
25) Display Salesman IDs and names of those who made no sales: