Sunteți pe pagina 1din 11

Ques 8 pg 632

Prac21
Ques Write SQL commands for (a) to (f) and outputs for (g) on the basis of tables
FURNITURE and ARRIVALS
(a) To show all information about Baby cots from the FURNITURE table
(b) To list the ITEMNAME which are priced at more than 15000 from the
FURNITURE table
(c) To list ITEMNAME and TYPE of those items, in which DATEOFSTOCK is
before 22/01/02 from the FURNITURE table in descending order of
ITEMNAME
(d) To display ITEMNAME and DATEOFSTOCK of those items, in which the
DISCOUNT percentage is more than 25 from FURNITURE table
(e) To count the number of items, whose TYPE is Sofa from FURNITURE table
(f) To insert a new row in the ARRIVALS table with the following data:
14, Velvet touch, Double bed, {25/03/03},30
(g) Give outputs for the following SQL statements [Outputs of the below
mentioned queries should be based on original data given in both the
tables i.e., without considering the insertion done in (f) part of this
question]
i.
Select COUNT(distinct TYPE) from FURNITURE;
ii.
Select MAX(DISCOUNT) from FURNITURE, ARRIVALS;
iii.
Select AVG(DISCOUNT) from FURNITURE where TYPE=Baby cot;
iv.
Select SUM(PRICE) from FURNITURE where
DATEOFSTOCK<{12/02/02};
Table :

Table :

(a)

(b)

*
(c)

(d)

(e)

(f)

(g)
(i)

*
(ii)

(iii)

*
(iv)

Ques 10 pg 633
Prac22
Ques 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 :

Table :

(i)
(ii)

(iii)
(iv)
(v)
(vi)

(i)

(ii)

Display NAME of all doctors who are in MEDICINE having more than 10
years of experience from the table DOCTOR
Display the average salary of all doctors who are working in ENT
department using the tables DOCTOR and SALARY
[Salary=BASIC+ALLOWANCE]
Display the minimum ALLOWANCE of female doctors
Display the highest consultation fee among all male doctors
SELECT count(*) from DOCTOR where SEX=F;
SELECT NAME, DEPT, BASIC from DOCTOR, SALARY WHERE DEPT=ENT
AND DOCTOR.ID=SALARY.ID;

*
(iii)

(iv)

(v)

(vi)

Ques 11 pg 634
Prac23
Ques
(a) What are DDL and DML commands?
(b) Study the following tables FLIGHTS and FARES and write SQL commands
for the questions (i) to (iv) and give outputs for SQL queries (v) to (vi)
Table :

Table :

i.
ii.
iii.

iv.
v.
vi.
(i)

(ii)

(iii)

*
(iv)

(v)

Display FL_NO and NO_FLIGHTS from KANPUR to BANGALORE


from the table FLIGHTS
Arrange the contents of the table FLIGHTS in the ascending order of
FL_NO
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 be
paid=FARE+FARE*TAX/100
Display the minimum fare Indian Airlinesis offering from the table
FARES
SELECT FL_NO, NO_FLIGHTS, AIRLINES from FLIGHTS, FARES WHERE
STARTING=DELHI AND FLIGHTS.FL_NO = FARES.FL_NO;
SELECT count(distinct ENDING) from FLIGHTS;

(vi)

Ques 12 pg 634
Prac24
Ques Consider the following tables Employees and Empsalary. Write SQL
commands for the statements (i) to (iv) and give outputs for SQL queries (v) to
(viii)
Table :

Table :

i.

To display Firstname, Lastname, Address and City of all employees living in


Paris from the table Employees

ii.
iii.

iv.
v.
vi.
vii.
viii.

(i)

(ii)

(iii)

(iv)

(v)

(vi)

To display the content of Employees table in descending order of


FIRSTNAME
To display the Firstname, Lastname, and Total Salary of all Managers from
the tables Employees and Empsalary, where Total Salary is calculated as
Salary+Benefits
To display the Maximum salary among Managers and Clerks from the table
Empsalary
SELECT FIRSTNAME, SALARY FROM Employees, Empsalary WHERE
DESIGNATION=Salesman AND Employees.EMPID=Empsalary.EMPID;
SELECT COUNT(DISTINCT DESIGNATION) FROM Empsalary;
SELECT DESIGNATION, SUM(SALARY) FROM Empsalary GROUP BY
DESIGNATION HAVING COUNT(*)>2;
SELECT SUM(BENEFITS) FROM Employees WHERE DESIGNATION=Clerk;

(vii)

(viii)

Ques 13 pg 636
Prac25
Ques Consider the following tables GARMENT and FABRIC. Write SQL commands
for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii)

Table :

Table :

i.
ii.

To display GCODE and DESCRIPTION of each GARMENT in descending


order of GCODE
To display the details of all the GARMENTs, which have READYDATE in
between 08-DEC-07 and 16-JUN-08 (both inclusive)

iii.
iv.

v.
vi.
vii.
viii.

(i)

(ii)

(iii)

(iv)

(v)

(vi)

To display the average PRICE of all GARMENTs, which are made up of


FABRIC with FCODE as F03
To display FABRIC wise highest and lowest price of GARMENTs from
GARMENT table. (Display FCODE of each GARMENT along with highest
and lowest price)
SELECT SUM(PRICE) FROM GARMENT WHERE FCODE=F01;
SELECT DESCRIPTION, TYPE FROM GARMENT, FABRIC WHERE
GARMENT.FCODE=FABRIC.FCODE AND GARMENT.PRICE>=1260;
SELECT MAX(FCODE) FROM FABRIC;
SELECT COUNT(DISTINCT PRICE) FROM GARMENT;

(vii)

(viii)

S-ar putea să vă placă și