Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

G12 Preboard Revision – WS3

1. Consider the following tables FACULTY and COURSES. Write the outputs of SQL statements (i) to (vi).
FACULTY
F_ID Fname Lname Hire_date Salary
102Amit Mishra 12-10-1998 12000
103Nitin Vyas 24-12-1994 8000
104Rakshit Soni 18-05-2001 14000
105Rashmi Malhotra 31-12-2000 11000
COURSES
C_ID F_ID Cname Fees
C21 102 Grid Computing 40000
C22 103 System Design 16000
C23 104 Computer Security 8000
C24 103 Human Biology
C25 102 Computer Network 20000
C26 105 Visual Basic 8000
i) Select F_ID, sum(Fees) from COURSES group by F_ID;
ii) Select concat(Fname,’ ‘,Lname) As Name, Hire_date from FACULTY Hire_date<’31-12-2000’;
iii) Select Fname, Cname from FACULTY, COURSES where COURSES.F_ID=FACULTY.F_ID and
COURSES.F_ID=102;
iv) Select Fname, Salary from Faculty where Fname like ‘%t’ and Salary > 12000;
v) Select Cname, fees from Courses where Fees=(Select min(Fees) from courses);
vi) Select F_ID, count(Fees) from Courses group by F_ID having count(Fees)>1;

2. Ashwin creates a table TEACHER with a set of records to maintain the data of teachers in an institute.
After creation of the table, he has entered data of 8 teachers in the table.
Write SQL commands for (a) to (c) based on Teacher relation given below:

Relation Teacher
ID Name Age Departme Date ofjoin Salary Sex
nt
S01 Jugal 34 Computer 10/01/97 12000 M
S02 Sharmila 31 History 24/03/98 20000 F
S03 Sandeep 32 Maths 12/12/96 30000 M
S04 Sangeeta 31 History 01/07/99 40000 F
S05 Rakesh 42 Maths 05/09/97 25000 M
S06 50 History 27/06/98 30000 M
S07 Shiv Om 42 Computer 25/02/97 21000 M
S08 Shalakha 33 Maths 31/07/97 20000 F

(i) Identify the most appropriate column, which can be considered as Primary key. Write SQL command
to add Primary key constraint to the table.
(ii) What is degree and cardinality of the resultant table obtained by the following query:
Select Name, Age from Teacher where Department=”History” and sex =’F’;
(iii) Write the SQL command to :
(a) To increase the salary of all Male math teachers by 10%
(b) To display department and number of teachers department wise

You might also like