0% found this document useful (0 votes)
73 views

SQL Practical List

The document provides a practical list of SQL queries and statements related to various tables containing employee, book, teacher, item, customer, and flight data. The queries and statements include selecting, filtering, sorting, aggregating, and performing calculations on the data in the tables. The document asks the reader to write SQL commands for the given statements and provide outputs for sample queries.

Uploaded by

Pritish Sarkar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

SQL Practical List

The document provides a practical list of SQL queries and statements related to various tables containing employee, book, teacher, item, customer, and flight data. The queries and statements include selecting, filtering, sorting, aggregating, and performing calculations on the data in the tables. The document asks the reader to write SQL commands for the given statements and provide outputs for sample queries.

Uploaded by

Pritish Sarkar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Practical List

SQL PRACTICAL LIST

CLASS XII – IP/CS

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.

(ii) To display the content of EMPLOYEES table in descending order of FIRSTNAME.

(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.

(v) SELECT COUNT (DISTINT DESIGNATION ) FROM EMPSALARY

(vi) SELECT SUM (BENEFITS) FROM EMPSALARY WHERE DESIGNATION=’Clerk’;

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).

TABLE : CONSIGNOR TABLE : CONSIGNEE

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

ND48 MU5 0 B P jain 13,Block d,a,viha New Delhi

(i) To display the names of all consignors from Mumbai.


(ii) To display the cneeID, cnorName, cnorAddress, CneeName, CneeAddress for every
Consignee.
(iii) To display the consignee details in ascending order of CneeName.
(iv) To display number of consignors from each city.
(v) SELECT DISTINCT City FROM Consignee;

Koushilya Patel,PGT CS,KV CME,Pune-31


Practical List
(vi) SELECT A.CnorName, B.CneeName FROM Consignor A, Consignee B WHERE
A.CnorID=B.CnorID AND B.CneeCity= ‘Mumbai;

Q.3) Consider the table BOOKS and ISSUED given below.


TABLE : BOOKS  TABLE:ISSUED
BOOK_I
BOOK_NAME AUTHONAME PUBLISHER PRICE TYPE QUANTITY BOOK_ID QUANTITY_ISSUED
D
F0001 The Tears William Hopkins First Publ 750 Fiction 10 F0001 3
F0002 Thund erbolts Anna Roberts First Publ. 700 Fiction 5 T0001 1
T0001 My first C+ + Brains & Brooke EPB 250 Text 10 C0001 5
C++ Brain
T0002 A.W.Ros saine TDH 325 Text 5
works
C001 Fast Cook Lata Kapoore EPB 350 Cookery 8

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.

(ii) To list the names of the books of FICTIONS type.

(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.

(v) Select Count(Distinct Publishers) From Books;

(vi)Select Sum(Price) From Books Where Quantity>5;

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

1 Tanya Nanda SocialStudies 1994-03-17 TGT F 25000

2 Saurabh Sharma Art 1990-02-12 PRT M 20000

3 Nandita Arora English 1980-05-16 PGT F 30000

4 James Jacob English 1989-10-16 TGT M 25000

5 Jaspreet Kaur Hindi 1990-08-01 PRT F 22000

6 Disha Sehgal Math 1980-03-17 PRT F 21000

7 Siddharth Kapoor Science 1994-09-02 TGT M 27000

8 Sonali Mukherjee Math 1980-11-17 TGT F 24500

i. To display all information about teachers of PGT category.


ii. To list the names of female teachers of Hindi department.
iii. To list names, departments and date of hiring of all the teachers in ascending order of date
of joining

Koushilya Patel,PGT CS,KV CME,Pune-31


Practical List
iv. To count the number of teachers in English department.
v. SELECT COUNT(*) FROM TEACHER WHERE Category = "PGT"
vi. SELECT AVG(Salary) FROM TEACHER group by Gender;

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

(i) To display the details of those Customers whose city is Delhi.


(ii) To display the details of Item whose Price is in the range of 35000 to 55000 (Both values
included).
(iii) To display the CustomerName, City from table Customer, and ItemName and Price from table
Item, with their corresponding matching I_ID.
(iv) To increase the Price of all Items by 1000 in the table Item.
(v) SELECT DISTINCT City FROM Customer.
(vi) SELECT ItemName, MAX(Price), Count(*) FROM Item GROUP BY ItemName;
(vii) SELECT ClientName, ManufacturerName FROM Product, Client WHERE
Client.Prod_Id=Product.P_Id;
(viii) SELECT ProductName, Price * 4 FROM Product.

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

Koushilya Patel,PGT CS,KV CME,Pune-31


Practical List
IC899 INDIAN AIRLINES 8300 4
IC302 INDIAN AIRLINES 4300 10
IC799 INDIAN AIRLINES 1050 10
MC101 DECCAN AIRLINES 3500 4

(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

Koushilya Patel,PGT CS,KV CME,Pune-31


Practical List
300 Robert Samuel 9 Fifth Cross Washington
335 Henry Williams 12Moore Street Boston
403 Ronny Lee 121 Harrison St. New York
451 Pat Thomps on 11 Red Road Paris

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

(ii) To display the content of workers table in ascending order of LASTNAME.

(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

(vi)SELECT COUNT(DISTINCT DESIGNATION) FROM DESIGN ;

(vii) SELECT DESIGNATION, SUM(SALARY) FROM DESIG GROUP BY DESIGNATION HAVING COUNT
(*) < 3;

(viii) SELECT SUM(BENIFTS) FROM DESIG WHERE DESIGINATION =”salesman”;

Koushilya Patel,PGT CS,KV CME,Pune-31

You might also like