Databases and SQL
Databases and SQL
Long Questions
Q1. Consider the tables EMPLOYEE and SALGRADE given below and answer (a) and
(ii) To display NAME and DESIG of those EMPLOYEEs whose SALGRADE is either S02 or S03.
(iii) To display the content of the entire EMPLOYEEs table, whose DOJ is in between ‘09-Feb-
2006’ and ‘08-Aug-2009’.
109,‘Harish Roy’,‘HEAD-IT’,‘S02’,‘9-Sep-2007’,‘21-Apr-1983’
Q2. Study the following table and write SQL queries for questions (i) to (iv) and output for (v)
and (vi).
(i) Write SQL query to display Pname, Quantity and Rate for all the orders that are either
Pencil or Pen.
(ii) Write SQL query to display the orders which are not getting any Discount.
(iii) Write SQL query to display the Pname, Quantity and Sale_date for all the orders whose
(iv) Write SQL query to display the orders whose Rate is in the range 20 to 100.
(vi) SELECT Pname, Quantity, Rate FROM Orders Order BY Quantity DESC;
Q3. Write SQL commands for (i) to (vi) on the basis of relations given below:
(ii) To display cost of all the books published for FIRST PUBL.
(iv) To display the BOOK_NAME and price of the books, more than 3 copies of which have
been issued.
(i) To show all information of students where capacity is more than the no. of students in
order of rtno.
(ii) To show area_covered for buses covering more than 20 km., but charges less than
80000.
(iii) To show transporter-wise total no. of students travelling.
(iv) To show rtno, area_covered and average cost per student for all routes where average cost
per student is—charges/noofstudents.
(v) Add a new record with the following data:
(11, “Motibagh”,35,32,10, “kisan tours”, 35000)
(vi)Give the output considering the original relation as given:
(a) select sum(distance) from schoolbus where transporter= “Yadav travels”;
(b) select min(noofstudents) from schoolbus;
(c) select avg(charges) from schoolbus where transporter= “Anand travels”;
(d) select distinct transporter from schoolbus;