Professional Documents
Culture Documents
QUERIES For Practical File 2023-24
QUERIES For Practical File 2023-24
1. Write a query to display PName, Price, PCode and Type from table Product.
SELECT PName, Price, PCode, Type
FROM Product;
2. Write a query to display different Companies (without repeat) from table Product.
SELECT DISTINCT ( Company )
FROM Product;
3. Write a query to display all the Products whose Price is more than 50.
SELECT *
FROM Product
WHERE Price > 50;
4. Write a query to display all the Products whose company is not Britannia.
SELECT *
FROM Product
WHERE Company != ‘Britannia’;
5. Write a query to display PName, Company and Price of all the products of Cadbury
company whose price is less than 100.
SELECT PName, Company, Price
FROM Product
WHERE Company = ‘Cadbury’ AND Price < 100 ;
7. Write a query to display PName and Price of all the Products whose price is between
60 and 100.
SELECT PName, Price
FROM Product
WHERE Price BETWEEN 60 AND 100;
1
8. Write a query to display all the Products of Company Dukes, Britannia, Sunfeast,
Candyman and Perfetti.
SELECT *
FROM Product
WHERE Company IN (‘Dukes’, ‘Britannia’, ‘Sunfeast’, ‘Candyman’,
‘Perfetti’);
9. Write a query to display all the Products having Price other than 40,45,50,55,60,65.
SELECT *
FROM Product
WHERE Price NOT IN (40, 45, 50, 55, 60, 65);
10. Write a query to display PName, Company and Price of all the Products whose
PName starts with alphabet M.
SELECT PName, Company, Price
FROM Product
WHERE PName LIKE “M%”;
11. Write a query to display all the Products not having alphabet ‘a’ as second character
in their PName.
SELECT PName
FROM Product
WHERE PName NOT LIKE “_a%” ;
12. Write a query to display all the Products having NULL value in Company column.
SELECT *
FROM Product
WHERE Company IS NULL;
13. Write a query to display all the records in the alphabetical order of PName.
SELECT *
FROM Product
ORDER BY PName ASC;
14. Write a query to display PName, Company and Price of Britannia and Cadbury
company in the order of their Price from highest to lowest.
SELECT PName, Company, Price
FROM Product
WHERE Company = ‘Britannia’ OR Company = ‘Cadbury’
ORDER BY Price DESC;
15. Write a query to display PName and New Price of Products. The New Price is
calculated as Price + 10% of Price.
SELECT PName, Price + Price*10/100 AS “New Price”
FROM Product;
17. Write a query to display Minimum Price from the products of type ‘B’.
SELECT MIN(Price)
FROM Product
WHERE Type = ‘B’;
2
Grouping Result: (GROUP BY clause)
19. Write a query to display Sum of Price of the Products of each Type.
SELECT Type, SUM(Price)
FROM Product
GROUP BY Type;
21. Write a query to display all the Companies where the number of Products are less
than 3.
SELECT Company, COUNT(*)
FROM Product
GROUP BY Company
HAVING COUNT(*) < 3;
3
JOIN QUERIES
Table: DEPT (Parent Table)
1. Write a query to display all the records from table Dept and Emp.
SELECT *
FROM Dept, Emp
WHERE Dept.DeptId = Emp.DeptId;
2. Write a query to display DeptId, DName, EName and Desig from Table Dept and
Emp.
3. Write a query to display PName, DName, Location and Salary of those Employees
whose Salary is more than 40000.
4. Write a query to display EId, DeptId, EName and DName of all the Managers.
----- X -----