P - File - 2 Ques
P - File - 2 Ques
5. Consider the following tables CABHUB and CUSTOMER. Write SQL commands for the
following : CABHUB
Vcode VehicleName Make Color Capacity Charges
100 Innova Toyota WHITE 7 15
102 SX4 Suzuki BLUE 4 14
104 C Class Mercedes RED 4 35
105 A-Star Suzuki WHITE 3 14
108 Indigo Tata SILVER 3 12
CUSTOMER
CCode CName VCode
1 Hemant Sahu 101
2 Raj Lal 108
3 Feroza Shah 105
4 Ketan Dhal 104
1. To display the names of all white colored vehicles.
2. To display name of vehicle, make and capacity of vehicles in ascending order of their
sitting capacity.
3. To display the highest charges at which a vehicle can be hired from CABHUB.
4. To display the customer name and the corresponding name of the vehicle hired by
them.
5. To display the average of charges at which a vehicle can be hired from CABHUB.
6. Consider the following DEPT and EMPLOYEE tables. Write SQL commands for the following:
DEPT
ADMIN
CODE GENDER DESIGNATION
1001 MALE VICE PRINCIPAL
1009 FEMALE COORDINATOR
1203 FEMALE COORDINATOR
1045 MALE HOD
1123 MALE SENIOR TEACHER
1167 MALE SENIOR TEACHER
1215 MALE HOD
1. To display TEACHERNAME, PERIODS of all teachers whose periods are less than 25.
2. To display TEACHERNAME, CODE and DESIGNATION from tables SCHOOL and ADMIN.
3. To display the TEACHERNAME who have minimum PERIODS.
4. To display CODE, TEACHERNAME and SUBJECT of all teachers who have joined the school
after 01/01/1999.
5. To display contents of both the tables.
8. Consider the following relation TEACHER and SALARY. Write SQL commands for the
following : TEACHER
TID FIRST_NAME LAST_NAME ADDRESS SUBJECT
010 Rohit Sharma 83, Lok Vihar English
105 Meeta Rathi 842, Rajauri Physics
152 Seema Verma 33, Safdarganj Maths
215 Sarad Singh 440, Ashok Vihar Physics
244 Manish Sengupta 24, New Street Maths
300 Ram Gupta 9, Fifth Road Chemistry
355 Heena Jain 12, Friends Street Computer
400 Rachit Sharma 10, Paschim Vihar Computer
441 Punit Jain 11, Rohini Chemistry
SALARY
TID SALARY BONUS DESIGNATION
010 7500 1500 PGT
105 8500 1500 PGT
152 6000 1200 TGT
215 7500 1500 PGT
1. To display FIRST_NAME, LAST_NAME and SUBJECT of all teachers of PHYSICS subject
2. To display all records in ascending order of LAST_NAME.
3. To display the TID, FIRST_NAME and total SALARY of all PGT from the table TEACHER and
SALARY, where total salary is calculated as SALARY + BONUS.
4. To display the ADDRESS of teachers SUBJECT wise.
5. To display the names of teachers whose bonus is more than 1000.
9. Write a menu driven program in Python to create a table (GYM) of SQL with the following
contents : (Python SQL Interface)
Mno member number integer, Mname member name string
Fee membership fee float, Address member address string
Gender member gender character, Write user defined functions to :
1. insert rows in this table. (using parameterized query concept)
2. display the rows
3. update rows (using parameterized query concept)
4. Display data in sorted order as per the user choice
5. Query based on group by clause