0% found this document useful (0 votes)
18 views

SQL Queries: S.no Pname Sname Qty Price City

The document contains sample data in a Supplier table with columns for Sno, Pname, Sname, Qty, Price and City. It then lists 15 SQL queries performed on this table including finding the average price, sum of quantity, minimum quantity, maximum price, products where quantity is greater than 300, number of items costing more than Rs. 10, inserting a new record, displaying distinct cities, number of products per city, updating prices less than Rs. 10, deleting items with quantity less than 200, ordering by quantity and price, displaying details where price is more than Rs. 250, displaying all details except for 'Cake', and displaying details where price is between Rs. 200-500.

Uploaded by

Ika
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

SQL Queries: S.no Pname Sname Qty Price City

The document contains sample data in a Supplier table with columns for Sno, Pname, Sname, Qty, Price and City. It then lists 15 SQL queries performed on this table including finding the average price, sum of quantity, minimum quantity, maximum price, products where quantity is greater than 300, number of items costing more than Rs. 10, inserting a new record, displaying distinct cities, number of products per city, updating prices less than Rs. 10, deleting items with quantity less than 200, ordering by quantity and price, displaying details where price is more than Rs. 250, displaying all details except for 'Cake', and displaying details where price is between Rs. 200-500.

Uploaded by

Ika
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL QUERIES

TABLE : SUPPLIER
S.no Pname Sname Qty Price City
S1 Bread Britannia 200 10 Delhi
S2 Cake Britannia 350 50 Mumbai
S3 Coffee Nescafe 475 45 Jaipur
S4 Chocolate Amul 500 15 Mumbai
S5 Sauce Maggi 150 40 Delhi
S6 Biscuit Good day 250 20 Chennai
S7 Waffers Britannia 300 20 Mumbai
S8 Sweets Haldirams 400 50 Nagpur

1. Display Avg of Price.


SELECT AVG(Price) “Average”
FROM Supplier;
2. Display Sum of Quantity.
SELECT SUM(Qty) “Sum”
FROM Supplier;
3. Display Minimum quantity of product.
SELECT MIN(Qty) “Minimum”
FROM Supplier;
4. Display Maximum amount of product.
SELECT MAX(Price) “ Maximum”
FROM Supplier;
5. Display Sname, Pname, Price for all product whose quatity is >300.
SELECT Sname, Pname, Price
FROM Supplier WHERE Qty>300
6. Display the number of items whose cost more than 10.
SELECT COUNT(*) FROM Supplier WHERE Price>10;
7. Insert a new record in the table:
“S9”,”Hot dog”,”Britannia”,200,20,”Delhi”
INSERT INTO Supplier
VALUES(“S9”,”Hot dog”,”Britannia”,200,20,”Delhi”);
8. Display distinct City of supplier.
SELECT DISTINCT(City)
FROM Supplier;
9. Display the number of products supplied from same city.
SELECT COUNT (*) “Number of products”, City
FROM Supplier
GROUP BY City;
10. Update all the prices with an increment of Rs. 5 where prices are less
than 10.
UPDATE Supplier
SET Prices=Prices+5
WHERE Prices<10;
11. Delete name of items where quantity is less than 200.
DELETE Pname FROM Supplier
WHERE Qty<200;
12. Display quantity in ascending and price in descending order.
SELECT * FROM Supplier
ORDER BY Qty ASC, Price DESC;
13. Display the product details whose price is more than 250.
SELECT * FROM Supplier
WHERE Price>250;
14. Display all the details of supplier except ‘Cake’
SELECT * FROM Supplier
WHERE NOT Pname=’Cake’;
15. Display Sname, Pname and city where price is between 200-500
SELECT Sname, Pname, City FROM Supplier
WHERE Price BETWEEN 200 AND 500;

You might also like