SQL Practicals
SQL Practicals
Consider the table SHOPPE and ACCESSORIES, write the query for (i) to (iv) and output
for (v)
i)To display Name and Price of all the Accessories in descending order of their Price.
(iii) To display Name, Minimum and Maximum Price of each Name from ACCESSORIES
table.
Mother Board
LCD
1
7. Consider the table items, write the query for (i) to (iv) and output for (v).
(i) To display all INAME from ITEMS table in descending order of their
PRICE.
Select INAME from items order by price desc;
(ii) To display all ITEMS details whose price is in range of 15000 and
25000.
Select * from items where price between 15000 and 25000;
(iii) To display Sum of price and TCode where Qty is more than 50
TCode wise (for each TCode)
Select sum(price), tcode from items where qty >50 group by tcode;
8. Consider the table employee, write the query for (i) to (iv) and output for (v):
(i) To display all the information of employee whose name begins with M
in ascending order of their DOB.
Select * from employee where name like ‘m%’ order by DOB;
(v)
Select Max(DOB), Min(DOB) from EMPLOYEE;
Max(DOB) Min(DOB)
1991-09-01 1984-10-19
9. Consider the table Transact, write the query for (i) to (iv) and output for (v):
TABLE: TRANSACT
TRNO ANO AMOUNT TYPE DOT
T001 101 2500 Withdraw 2017-12-21
T002 103 3000 Deposit 2015-06-01
T003 102 2000 Withdraw 2017-05-12
T004 103 1000 Deposit 2017-10-22
T005 102 12000 Deposit 2016-11-06
(i) To display details of all transactions of TYPE Withdraw from TRANSACT table.
Select * from TRANSACT where TYPE=’Withdraw’;
(ii) To display ANO and AMOUNT of all Deposit and Withdrawals done in month of
“May” 2017 from table TRANSACT.
Select ANO, AMOUNT from TRANSACT where DOT like ‘%-05-%’;
(iii) To display first date of transaction (DOT) from table TRANSACT for Account having
ANO as 102.
Select MIN(DOT) from TRANSACT where ANO=102;
(iv) To display ANO, AMOUNT, TYPE of those transactions done in the year
2017;
Select ano,amount,type from transact where DOT like ‘2017%’;
(i) To display PCode, PName of all the product, who manufacture “Samsung”.
Select Pcode, Pname from product where manufacture=” Samsung”;
(ii) To display PName, PCode and price of all the products whose price >=23000.
Select Pname, Pcode, Price from Product where price>=23000;
3
(iii)To display number of product manufacture wise.
Select count (*) from Product group by Manufacture;