SQL Question Paper - 2
SQL Question Paper - 2
1. Consider the following tables SCHOOL and ADMIN and answer this question:
Give the output the following SQL queries:
1. Select Designation Count (*) From Admin Group By Designation Having Count (*) <2;
2. SELECT max (EXPERIENCE) FROM SCHOOL;
3. SELECT TEACHER FROM SCHOOL WHERE EXPERIENCE >12 ORDER BY TEACHER;
4. SELECT COUNT (*), GENDER FROM ADMIN GROUP BY GENDER;
2. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based
on the tables TRANSPORT and TRIP
1. To display those company name which are having prize less than 30000.
2. To display the name of the companies in reverse alphabetical order.
3. To increase the prize by 1000 for those customers whose name starts with “S”?
4. To add one more column totalprice with decimal] 10,2) to the table customer
5. SELECT COUNT(*) , CITY FROM COMPANY GROUP BY CITY;
6. SELECT MIN(PRICE), MAX(PRICE) FROM CUSTOMER WHERE QTY>10;
7. SELECT AVG(QTY) FROM CUSTOMER WHERE NAME LIKE “%r%;
8. SELECT PRODUCTNAME,CITY, PRICE FROM COMPANY, CUSTOMER WHERE
COMPANY. CID=CUSTOMER.CID AND PRODUCTNAME=”MOBILE”;
4. Consider the following tables SCHOOL and ADMIN and answer this question:
1. TO DISPLAY ALL THE DETAILS OF THOSE WATCHES WHOSE NAME ENDS WITH ‘TIME’
2. TO DISPLAY WATCH’S NAME AND PRICE OF THOSE WATCHES WHICH HAVE PRICE RANGE IN
BE-TWEEN 5000-15000.
3. TO DISPLAY TOTAL QUANTITY IN STORE OF UNISEX TYPE WATCHES.
4. TO DISPLAY WATCH NAME AND THEIR QUANTITY SOLD IN FIRST QUARTER;
5. SELECT MAX (PRICE), MIN(QTY_STORE) FROM WATCHES;
6. SELECT QUARTER, SUM(QTY SOLD) FROM SALE GROUP BY QUARTER;
7. SELECT WATCH_NAME, PRICE, TYPE FROM WATCHES W, SALE S WHERE W.
WAT£H1D!=S.WATCHID; (viii) SELECT WATCH_NAME, QTYSTORE, SUM (QTY_SOLD),
QTY_STORESUM (QTYSOLD) “STOCK” FROM WATCHES W, SALE S WHERE W. WATCHID =
S.WATCHID GROUP BY S.WATCHID;
1. To display name, fee, gender, joinyear about the applicants, who have joined before 2010.
2. To display names of applicants, who are playing fee more than 30000.
3. To display names of all applicants in ascending order of their joinyear.
4. To display the year and the total number of applicants joined in each YEAR from the table
APPLICANTS.
5. To display the C_ID (i.e., CourselD) and the number of applicants registered in the course
from the APPLICANTS and table.
6. To display the applicant’s name with their respective course’s name from the tables
APPLICANTS and COURSES.
7. Give the output of following SQL statements:
o SELECT Name, Joinyear FROM APPLICANTS WHERE GENDER=’F’ and C_ID=’A02′;
o SELECT MIN (Joinyear) FROM APPLICANTS WHERE Gender=’m’;
o SELECT AVG (Fee) FROM APPLICANTS WHERE C_ID=’A0T OR C_ID=’A05′;
o SELECT SUM- (Fee), C_ID FROM C_ ID GROUP BY C_ID HAVING COUNT(*)=2;
1. To display the details of all the items in ascending order of item names (i.e., INAME).
2. To display item name and price of all those items, whose price is in the range of 10000 and
22000 (both values inclusive).
3. To display the number of items, which are traded by each trader. The expected output of this
query should be:
4. To display the price, item name and quantity (i.e., qty) of those items which have quantity more
than 150.
5. To display the names of those traders, who are either from DELHI or from MUMBAI.
6. To display the names of the companies and the names of the items in descending order of
company names.
7. Obtain the outputs of the following SQL queries based on the data given in tables ITEMS and
TRADERS above.
o SELECT MAX (PRICE), MIN (PRICE) FROM ITEMS;
o SELECT PRICE*QTY FROM ITEMS WHERE CODE-1004;
o SELECT DISTINCT TCODE FROM ITEMS;
o SELECT INAME, TNAME FROM ITEMS I, TRADERS T WHERE I.TCODE=T.TCODE AND QTY< 100;
9. Write SQL queries for (a) to (f) and write the outputs for the SQL queries mentioned shown in
(g) parts on the basis of tables PRODUCTS and SUPPLIERS
a) To display the details of all the products in ascending order of product names (i.e., PNAME).
b) To display product name and price of all those products, whose price is in the range of 10000
and 15000 (both values inclusive).