SQL
SQL
1 Write the SQL commands for the i) to iv) and write the output of the (v) on the basis of table
TEACHER.
Table:TEACHER
Q.2
TABLE : GRADUATE
S.NO NAME STIPEND SUBJECT AVERAGE DIV.
1 KARAN 400 PHYSICS 68 I
2 DIWAKAR 450 COMP. Sc. 68 I
3 DIVYA 300 CHEMISTRY 62 I
4 REKHA 350 PHYSICS 63 I
5 ARJUN 500 MATHS 70 I
6 SABINA 400 CEHMISTRY 55 II
7 JOHN 250 PHYSICS 64 I
8 ROBERT 450 MATHS 68 I
9 RUBINA 500 COMP. Sc. 62 I
10 VIKAS 400 MATHS 57 II
1.List the names of those students who have obtained I DIV sorted by NAME.
2.Display a report, listing NAME, STIPEND, SUBJECT and amount of stipend received in a year
assuming that the STIPEND is paid every month.
3.To count the number of students who are either PHYSICS or COMPUTER SC graduates.
4.To insert a new row in the GRADUATE table:
11,”KAJOL”, 300, “computer sc”, 75, 1
Q.3 Write SQL command for (i) to (vii) on the basis of the table SPORTS
Table: SPORTS
(a) Display the names of the students who have grade ‘C’ in either Game1 or
Game2 or both.
(b) Display the number of students getting grade ‘A’ in Cricket.
(c) Display the names of the students who have same game for both Game1 and
Game2.
(d) Display the games taken up by the students, whose name starts with ‘A’.
(e) Assign a value 200 for Marks for all those who are getting grade ‘B’ or grade ‘A’
in both Game1 and Game2.
Q.4
Employees
Q 5. Study the following table and then answer the given questions:
Table : SchoolBus
Q 6. Consider the following tables PRODUCT and answer (b) and (c) part of this question
Relation :PRODUCT
TABLE: STAFF
TABLE: SALARY
(i) Display NAME of all the staff who is in SALES having more than 10 year experience from
the table staff.
(ii) Display the average Basic Salary of all staff working in ”Finance” department using the table
staff and salary.
(iii)Display the minimum ALLOWANCE of female staff.
(iv) Display the highest commission among all male staff
(8) Write the SQL commands for the i) to iv) and write the output of the v) and vi) on the basis of
table TEACHER.
Table:TEACHER
vi) To display the list of all male teachers who are in Maths department.
vii) To display Names, Age and Sex of all teachers with their date of admission in descending
order.
viii) To insert a new row in the TEACHER table with the following data:
9,’Raja’, 26,’Computer’, {13/05/95}, 23000,’M’
9. Consider the table Flight given below, write command in SQL for (1) to (4) and output for (5) to (
Table : FLIGHT
(4) To display flight details of the flight whose flightdate is after Jan 2008.
(10) Consider the following table Customer of On-line Trading with details of customers. Write MySQL
command for (a) to (d) and output for (e) to (h).
Table: CUSTOMER
a) To display customer name, city and amount of those customers whose name is greater than
5 characters long.
b) To change ‘LG’ with ‘Lifes Good’ in product column.
c) To increase size of CustName as 40 characters.
d) To display CustName, Product and TaxAmount as 3% of Amount.
11. Consider the table Hospital given below. Write commands in MySQL for (i) to (iv) and
output for (v) to (vii).
(i) To show all information of patients who are in Orthopedic department from
hospital table in descending order of their age.
(ii) Increase the charges of male patient in ENT department by 4%.
(iii) Display a report listing name, age, charges and amount of charges including
VAT as 2% on charges, name the column as total charges.
(iv) To count the number of patients with Age < 30.
12-Write queries based on the following “EMP” Table:
EMP
13) Consider the table FLIGHT given below. Write commands in SQL for (i) to (iv) and output for (v)
to (vii).
(iv) Display destinations along with flight codes of all the destinations starting with ‘A’.