SQL Practical List
SQL Practical List
Q.1) Consider the following tables EMPLOYEES and EMPSALARY. write SQL commands for the Statements (i) to (iv) and give
outputs for SQL queries (v) & (vi).
Table : EMPLOYEEEMPLOYEES Table : EMPSALARY
EMPID FIRSTNAME LASTNAME ADDRESS CITY EMPID SALARY BENEFITS DESIGNATION
010 GEORGE Smith 83 First Street Howard 100 75000 15000 Manager
105 MARY Jones 842VineAve Losantiville 105 65000 15000 Manager
152 SAM Tones 33 Elm st Paris 152 80000 25000 Director
215 SARAH Ackerman 440 U.S.110 Upton 215 75000 12500 Manager
24
244 MANILA Sengupta New Delhi 244 50000 12000 Clerk
FriendsStreet
300 ROBERT Samuel 9 Fifth Cross Washington 300 45000 10000 Clerk
12 Moore
335 HENRY Williams Boston 335 40000 10000 Clerk
Street
400 RACHEL Lee 121 Harrison New York 400 32000 7500 Salesman
441 PETER Thompson 11 Red road Paris 441 28000 7500 Salesman
(i) To display Firstname, Lastname, Address and City of all employees living in Paris from the table
EMPLOYEES.
(iii) To display the Firstname, Lastname, and Total Salary of all managers from the tables, where Total
Salary is calculated as Salary+Benifts.
(iv) To display the Maximum salary among Managers and Clerks from the table EMPSALARY.
Q.2) Consider the following tables CONSIGNOR and CONSIGNEE. write SQL commands for the Statements (i) to (iv) and give
outputs for SQL queries (v) & (vi).
CnorI
CnorID CnorName CnorAddress City CneeID CneeName CneeAddress CneeCity
D
ND01 R singhal 24,ABC Enclave New Delhi MU05 ND01 RahulKishore 5,Park Avenue Mumbai
ND02 AmitKumar 123,Palm Avenue New Delhi ND08 ND02 P Dhingr a 16/j,Moore Enclave New Delhi
MU15 R Kohil 5/A,South,Street Mumbai KO19 MU15 A P Roy 2A,Central/ avenue Kolkata
MU50 S Kaur 7-K,Westend Mumbai MU32 ND0 2 S mittal P 245, AB Colony Mumbai
write SQL commands for the Statements (i) to (iv) and give outputs for SQL queries (v) & (vi).
(i)To show Book name, Author name and Price of books of EPB publisher.
(iii) To display the names and prices of the books in descending order of their price.
(iv) To Display the Book_ID, Book_Name and Quantity Issued for all books Which have been issued.
Q.4) Consider the table TEACHER given below. write SQL commands for the Statements (i) to (iv) and give outputs for SQL
queries (v) & (vi).
TEACHER
I
D Name Department Hiredate Category Gender Salary
Q.5 Consider the following tables Item and Customer. Write SQL commands for the statement (i) to
(iv) and give outputs for SQL queries (v) to (viii).
Table: ITEM Table: CUSTOMER
P_ID ItemName Manufacturer Price C_ID CustomerName City P_ID
PC01 Personal Computer ABC 35000 01 N.Roy Delhi LC03
LC05 Laptop ABC 55000 06 H.Singh Mumbai PC03
PC03 Personal Computer XYZ 32000 12 R.Pandey Delhi PC06
PC06 Personal Computer COMP 37000 15 C.Sharma Delhi LC03
LC03 Laptop PQR 57000 16 K.Agarwalh Banglore PC01
Q.6 Study the following tables FLIGHTS and FARES and write SQL commands for the questions (i) to
(iv).
TABLE: FLIGHTS
FL_NO STARTING ENDING NO_ FLGHTS NO_ STOPS
IC301 MUMBAI DELHI 8 0
IC799 BANGALORE DELHI 2 1
MC101 INDORE MUMBAI 3 0
IC302 DELHI MUMBAI 8 0
AM812 KANPUR BANGLORE 3 1
IC899 MUMBAI KOCHI 1 4
AM501 DELHI TRIVENDRUM 1 5
MU499 MUMBAI MADRAS 3 3
IC701 DELHI AHMEDABAD 4 0
TABLE: FLIGHTS
FL_NO AIRLINES FARE TAX%
IC701 INDIAN AIRLINES 6500 10
MU499 SAHARA 9400 5
AM501 JET AIRWAYS 13450 8
(i) Display FL_NO and NO_FLIGHTS from “KANPUR” TO “BANGALORE” from the table FLIGHTS.
(ii) Arrange the contents of the table FLIGHTS in the ascending order of FL_NO.
(iii) Display the FL_NO and fare to be paid for the flights from DELHI to MUMBAI using the tables
FLIGHTS and FARES, where the fare to paid = FARE+FARE+TAX%/100.
(iv) Display the minimum fare “Indian Airlines” is offering from the tables FARES.
Q.7 Study the following tables DOCTOR and SALARY and write SQL commands for the questions (i) to
(iv) and give outputs for SQL queries (v) to (vi) :
TABLE: DOCTOR TABLE: SALARY
ID NAME DEPT SEX EXPERIENCE ID BASIC ALLOWANCE CONSULTAION
101 Johan ENT M 12 101 12000 1000 300
104 Smith ORTHOPEDIC M 5 104 23000 2300 500
107 George CARDIOLOGY M 10 107 32000 4000 500
114 Lara SKIN F 3 114 12000 5200 100
109 K George MEDICINE F 9 109 42000 1700 200
105 Johnson ORTHOPEDIC M 10 105 18900 1690 300
117 Lucy ENT F 3 130 21700 2600 300
111 Bill MEDICINE F 12
(i) Display NAME of all doctors who are in “MEDICINE” having more than 10 years experience
from the Table DOCTOR.
(ii) Display the average salary of all doctors working in “ENT” department using the tables.
DOCTORS and SALARY Salary =BASIC+ALLOWANCE.
(iii) Display the minimum ALLOWANCE of female doctors.
(iv) Display the highest consultation fee among all male doctors.
(v) SELECT count (*) from DOCTOR where SEX = “F”
(vi) SELECT NAME, DEPT , BASIC from DOCTOR, SALRY Where DEPT = “ENT” AND DOCTOR.ID
= SALARY.ID
Q. 8)Consider the following tables WORKERS and DESIG. Write SQL commands for the statements (i)
to (iv) and give outputs for SQL queries (v) to (viii).
WORKERS
W_ID FIRSTNAME LASTNAME ADDRESS CITY
102 Sam Tones 33 Elm St. Paris
105 Sarah Ackerman 44 U.S.110 NewYork
144 Manila Sengupta 24 Friends Street New Delhi
210 George Smith 83 First Street Howard
255 Mary Jones 842 Vine Ave. Losantiville
DESIG
DESIGINA
W_ID SALARY BENEFITS
TION
102 75000 15000 Manager
105 85000 25000 Director
144 70000 15000 Manager
210 75000 12500 Manager
255 50000 12000 Clerk
300 45000 10000 Clerk
335 40000 10000 Clerk
400 32000 7500 Salesman
451 28000 7500 Salesman
(i) To display W_ID Firstname, address and City of all employees living in New York from the Table
WORKERs
(iii) To display the FIRSTNAME, LASTNAME and Total Salary of all Clerks from the tables WORKERS
And DESIG, where Total salary is calculated as Salary + benifts.
(iv) To display the minimum salary among managers and Clerks from the tables DESIG.
(v) SELECT FIRSTNAME, SALARY FROM WORKERS, DESIG WHERE DESIGINATION = “MANAGER”
AND WORKERS.W_ID = DESIGN.W_ID
(vii) SELECT DESIGNATION, SUM(SALARY) FROM DESIG GROUP BY DESIGNATION HAVING COUNT
(*) < 3;