0% found this document useful (0 votes)
607 views8 pages

SQL Queries for Relational Database Exam

This document contains 9 multiple choice questions related to relational databases and SQL. Each question includes tables and asks to write SQL queries to retrieve or manipulate data, or provides SQL queries and asks for their output. The questions cover topics such as selecting columns, primary keys, joins, aggregation, sorting, filtering, inserting data, and more.

Uploaded by

Sonika Dogra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
607 views8 pages

SQL Queries for Relational Database Exam

This document contains 9 multiple choice questions related to relational databases and SQL. Each question includes tables and asks to write SQL queries to retrieve or manipulate data, or provides SQL queries and asks for their output. The questions cover topics such as selecting columns, primary keys, joins, aggregation, sorting, filtering, inserting data, and more.

Uploaded by

Sonika Dogra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

CHAPTER -12

RELATIONAL DATABASE & SQL

BASED OF PREVIOUS YEAR’S FINAL EXAMINATION

Q1. Observe the following table carefully and write the names of the most appropriate
columns, which can be considered as (i) candidate keys and (ii) primary key.

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

(i) To display GCODE and DESCRIPTION of each GARMENT in descending order of


GCODE

(ii) To display the details of all the GARMENTs, which have READYDATE in between 08-
DEC-07 and 16-JUN-08 (inclusive of both the dates).
(iii) To display the average PRICE of all the GARMENTs, which are made up of FABRIC
with FCODE as F03.

(iv) To display FABRICwise highest and lowest price of GARMENTs from GARMENT
table. (Display FCODE of each GARMENT along with highest and lowest price).

(v) SELECT SUM(PRICE) FROM GARMENT WHERE FCODE=‟F01‟.

(vi) SELECT DESCRIPTION, TYPE FROM GARMENT, FABRIC WHERE


GARMENT.FCODE =FABRIC.FCODE AND GARMENT.PRICE > = 1260.

(vii) SELECT MAX(FCODE) FROM FABRIC.

(viii) SELECT COUNT (DISTINCT PRICE) FROM GARMENT.

Q4. Consider the following tables STORE and SUPPLIERS and answer (i) and (iv) parts of
this question and give outputs for SQL queries (v) to (viii):

(i) To display details of all the items in the Store table in ascending order of LastBuy.

(ii) To display ItemNo and Item name of those items from Store table Whose Rate is more
than 15 Rs.

(iii)To display the details of those items whose Suppliers code (Scode) is 22 or Quantity in
Store (Qty) is more than 110 from the table Store.

(iv) To display Minimum Rate of items for each Supplier individually as per Scode from the
table Store.

(v) SELECT COUNT (DISTINCT Scode) FROM Store;

(vi) SELECT Rate*Qty FROM Store WHERE ItemNO = 2004;

(vii)SELECT Item, Sname FROM Store S, Suppliers P WHERE S.Scode = P.Scode AND
Item No = 2006 ;

(viii) SELECT MAX (LastBuy) FROM Store ;

Q5. Consider the following tables WORKER and PAYLEVEL and answer (a) and (b) parts
of this question:
a) Write SQL commands for the following statements:

(i) To display the details of all WORKERs, descending order of DOB.

(ii) To display NAME and DESIG of those WORKERs whose PLEVEL is either P001 or
P002.

(iii)To display the content of all the WORKERs table, whose DOB is in between „19-JAN-
1984‟ and 18-JAN-1987‟.

(iv) To add a new row with the following :

19, „Days Kishore‟, „Operator‟, „P003‟. „19-Jun-2008‟, „11-Jul-1984‟

b) Give the output of the following SQL queries :

(i) SELECT COUNT (PLEVEL), PLEVEL FROM WORKER GROUP BY PLEVEL;

(ii) SELECT MAX(DOB), MIN(DOJ) FROM WORKER;

(iii) SELECT Name, Pay FROM WORKER W, PAYLEVEL P WHERE W.PLEVEL =


S.PLEVEL AND P.ECODE<13;

(iv) SELECT PLEVEL, PAY+ALLOWANCE FROM PAYLEVEL WHERE PLEVEL =


‘P003’;

Q6. Consider the following tables CARDON and CUSTOMER and answer following parts
of this question:
Q7. Consider the following tables ITEMS and TRADERS and answer following parts of this
question:
Q8. Consider the following tables ITEM and STORE and answer following parts of this
question:
Q 9.Consider the following DEPT and WORKER tables. Write SQL queries for (i) to (iv)
and find outputs for SQL queries (v) to (viii) :
Note : DOJ refers to date of joining and DOB refers to date of Birth of workers.

(i) To display Wno, Name, Gender from the table WORKER in descending order of Wno.

(ii) To display the Name of all the FEMALE workers from the table WORKER.

(iii) To display the Wno and Name of those workers from the table WORKER who are born
between ‘1987-01-01’ and ‘1991-12-01’.

(iv) To count and display MALE workers who have joined after ‘1986-01-01’.

(v) SELECT COUNT(*), DCODE FROM WORKER GROUP BY DCODE HAVING


COUNT(*)>1;

(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;

(vii) SELECT NAME, DEPARTMENT, CITY FROM WORKER W,DEPT D WHERE


W.DCODE=D.DCODE AND WNO<1003;

(viii) SELECT MAX(DOJ), MIN(DOB) FROM WORKER;

You might also like