SQL File
SQL File
Submitted
By
VAIBHAV ARORA
XII – H ROLL NO. 19
BOARD ROLL NO.
----------------------------------------------
TO
(iii) To display the highest charges at which a vehicle can be hired from
CABHUB.
(iv) To display the customer name and the corresponding name of the
vehicle hired by them.
1(i)
(ii)
(iii)
(iv)
2(i)
(ii)
(iii)
(iv)
Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii),
which are based on the tables.
(ii) To display the ANO and AMOUNT of all Deposits and Withdrawals are
done in the month of October 2017 from table TRANSACT.
(iii) To display the last date of transaction (DOT) from the table TRANSACT for
the Accounts having ANO as 103.
(iv) To display all ANO, ANAME and DOT of those persons from tables
ACCOUNT and TRANSACT who have done transactions less than or equal
to 3000.
(v) SELECT ANO. ANAME FROM ACCOUNT WHERE ADDRESS NOT IN
('CHENNAI', 'BANGALORE');
(vii) SELECT ANO. COUNT (*), MIN (AMOUNT) FROM TRANSACT GROUP BY
ANO HAVING COUNT (*) > 1;
(viii) SELECT COUNT (*), SUM (AMOUNT) FROM TRANSACT WHERE D0T<=
'2017-06-01';
TABLE: ACCOUNT
TABLE: TRANSACT
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)
(viii)
Write sql queries for (i) to (iv) and find outputs for sql queries (v) to (viii) which
are based on the tables
TABLE: BOOK
(i) (ii)
(iii)
(iv) and (v)
(vi)
(vii)
(viii)
Write SQL queries for (b) to (g) and write the outputs for the SQL queries
mentioned on the basis of tables PRODUCTS and SUPPLIERS
2. To display product name and price of all those products, whose price is in
the range of 10000 and 15000 (both values inclusive).
4. To display the price, product name and quantity (i.e., qty) of those
products which have quantity more than 100.
5. To display the names of those suppliers, who are either from DELHI or
from CHENNAI.
6. To display the name of the companies and the name of the products in
descending order of company names.
(b) ANSWERS
(c)
(d)
(e)
(f)
(g)
Write SQL queries for (b) to (g) on the basis of table ITEMS and TRADERS
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:
T01 2
T02 2
T03 1
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.
ANSWERS
(a)
(b) ccc
(c)
(e)
(f)
(g)
Write sql queries for (i) to (iii) and outputs for (iv) to (vii) based on the tables
ITEM and SALESPERSON.
TABLE : ITEM
TABLE : SALESPERSON
(i) TO DISPLAY THE CODE AND NAME OF ALL SALESPERSON HAVING “I7”
ITEM TYPE CODE FROM THE TABLE SALESPERSON.
(ii) TO DISPLAY ALL DETAILS FROM TABLE SALESPERSON IN DESCENDING
ORDER OF SALARY;
(iii) TO DISPLAY THE NUMBER OF SALESPERSON DEALING IN EACH TYPE OF
ITEM. (USE ITCODE FOR THE SAME)
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)
Write SQL queries for (i) to (v) as mentioned below based on the tables
TEACHER and TABLEPOSTING.
(i) TO SHOW ALL INFORMATION ABOUT THE TEACHER OF HISTORY
DEPARTMENT.
(ii) TO LIST THE NAMES OF FEMALE TEACHERS WHO ARE IN MATHEMATICS
DEPARTMENT.
(iii) TO LIST THE NAMES OF ALL TEACHERS WITH THEIR DATE OF JOINING IN
ASCENDING ORDER.
(iv) TO DISPLAY TEACHER’S NAME, SALARY, AGE FOR MALE TEACHERS ONLY.
(iv) TO DISPLAY NAME, BONUS FOR EACH TEACHER WHERE BONUS IS 10% OF
SALARY.
ANSWERS
(i)
(ii)
(iii)
(iv)
(v)
Write sql queries for (i) to (iv) and output for (v) to (viii) based on tables STORE
AND ITEM1.
(i) TO DISPLAY INAME AND PRICE OF ALL THE ITEMS IN ASCENDING ORDER
OF THEIR PRICE.
(ii) TO DISPLAY SNO AND SNAME OF ALL STORES LOCATED IN CP.
(iii) TO DISPLAY MINIMUM AND MAXIMUM PRICE OF EACH INAME FROM THE
TABLE ITEM.
(iv) TO DISPLAY LNAME, PRICE OF ALL ITEMS AND THEIR RESPECTIVE SNAME
WHERE THEY ARE AVAILABLE.
(iv) SELECT DISTINCT INAME FROM ITEM WHERE PRICE >= 5000;
(v) SELECT AREA, COUNT(*) FROM STORE GROUP BY AREA;
(vi) SELECT COUNT (DISTINCT AREA) FROM STORE;
(vii) SELECT INAME, PRICE * 0.05 DISCOUNT FROM ITEM1 WHERE SNO IN
('S02’,’S03');
ANSWERS
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)
(viii)
Write sql queries for (i) to (iv) and output for (v) to (viii) based on tables DEPT.
and EMPLOYEE.
(iv) TO COUNT AND DISPLAY FEMALE EMPLOYEES WHO HAVE JOINED AFTER
‘1986-01-01’.
(v) SELECT COUNT (*), DCODE FROM EMPLOYEE GROUP BY DCODE HAVING
COUNT (*)>1;
TABLE : EMPLOYEE
TABLE : DEPT.
ANSWERS
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)
(viii)
Write sql queries for (i) to (iv) and output for queries (v) to (viii) based on tables
DVD and MEMBER.
(i) TO DISPLAY ALL DETAILS FROM THE TABLE MEMEBER IN DESCENDING
ORDER OF ISSUEDATE.
(ii) TO DISPLAY THE DCODE AND DTITLE OF ALL FOLK TYPE DVDS FROM
THE TABLE DVD.
(iii) TO DISPLAY THE DTYPE AND NUMBER OF DVDS IN EACH DTYPE FROM
THE TABLE DVD.
(iv) TO DISPLAY ALL NAME AND ISSUEDATE OF THOSE MEMBERS FROM
THE TABLE MEMBER WHO HAVE DVDS ISSUED (I.E., ISSUEDATE) IN THE
YEAR 2017. (v)SELECT MIN(ISSUEDATE) FROM MEMBER;
(v) SELECT DISTINCT DTYPE FROM DVD;
(vi) SELECT D. DCODE, NAME, DTITLE FROM DVD D, MEMBER M WHERE D.
DCODE=M.DCODE;
(vii) SELECT DTITLE FROM DVD WHERE DTYPE NOT IN ("FOLK",
"CLASSICAL");
ANSWERS
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)
(viii)