Practical File XII (SQL-TERM 2)
Practical File XII (SQL-TERM 2)
1. Write SQL commands for (a) to (f) and write the output of (g) on the basis of table HOSPITAL:
Table: HOSPITAL
2. Write SQL commands for (a) to (e) and write the output of (f) on the basis of table CLUB:
Table: CLUB
(a) To display Mname, Age, Fees of those members of CLUB whose fees is between 5000 and
11000.
(b) To display Mcode, Mname, Age of all female members of the CLUB with age in descending
order.
(c) To display Mname, Age, Type of members of the CLUB with Mname in ascending order.
(d) To display Mname, Fees of all those members of the CLUB whose Age < 40 and are Monthly
type members of the CLUB.
(e) To get a new tuple in the table CLUB with following data:
11, ‘Vaibhav’, ‘Male’, 31, 900, ‘Guest’
(f) Write the output of following statements:
i. SELECT MAX(Fees) FROM Club;
ii. SELECT SUM(Fees) FROM Club WHERE Age > 35;
iii. SELECT AVG(Age) FROM CLUB WHERE Type = ‘Monthly’;
3. Write SQL commands for (a) to (f) and write the output of (g) on the basis of table LAB:
Table: CLUB
4. Write SQL commands for (a) to (f) and write the output of (g) on the basis of table LAB:
Table: SHOP
(a) To display the names of all shops which are in the area SOUTH.
(b) To display name and customer percentage of all shops having Cust_Percent > 80.
(c) To display list of all shops with sale > 300000 in ascending order of Shop_Name.
(d) To display a report with Shop_Name, Area, and Rating for each shop in the table, for only
those shops whose sale is between 350000 and 400000 (both inclusive).
(e) To display the city and number of shops in each city in the table SHOP.
(f) To insert details of new shop with the following data:
7, ‘The Shop’, 550000, ‘South’, 90.8, ‘A’, ‘Ahmedabad’
(g) Write the output of following statements.
i. SELECT MIN(Cust_Percent) FROM Shop;
ii. SELECT SUM(Sale) FROM Shop WHERE Rating = ‘A’;
iii. SELECT AVG(Sale) FROM Shop WHERE City = ‘Delhi’;
iv. SELECT COUNT(DISTINCT City) FROM Shop;
5. In a database create the following tables with suitable constraints. Based on these tables write SQL
statements for the following queries:
Table: ITEMS
Table: BILLS