0% found this document useful (0 votes)
289 views

SQL File

This document contains a student's SQL project file submitted to their computer science teacher. It includes an acknowledgement thanking the teacher and principal for allowing the student to complete the project. The student expresses that the teacher provided motivation and helped correct mistakes and ensure timely completion.

Uploaded by

Vaibhav Arora
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
289 views

SQL File

This document contains a student's SQL project file submitted to their computer science teacher. It includes an acknowledgement thanking the teacher and principal for allowing the student to complete the project. The student expresses that the teacher provided motivation and helped correct mistakes and ensure timely completion.

Uploaded by

Vaibhav Arora
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

MY SQL PROJECT FILE

Submitted
By

VAIBHAV ARORA
XII – H ROLL NO. 19
BOARD ROLL NO.

----------------------------------------------
TO

Mr. Arun Khanna


(Computer Science Teacher)
ACKNOWLEDGEMENT

I would like to show my special thanks of


gratitude to my teacher, Mr. Arun Khanna
and the Principal, Dr. (Mrs.) Bhawna Malik
who gave me the golden opportunity to do
this wonderful project of Computer Science.
He gave me motivation time to time while
doing this project, helped me in correcting
mistakes in project and also helped me to
complete this project on time.
Consider the following tables CABHUB and CUSTOMER and answer 1 and 2 parts
of this question:

1. Write SQL commands for the following statements:

(i) To display the names of all the white coloured vehicles.

(ii) To display name of vehicle name and capacity of vehicles in


ascending order of their sitting capacity.

(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.

2. Give the output of the following SQL queries:

(i) SELECT COUNT (DISTINCT Make) FROM CABHUB;

(ii) SELECT MAX (Charges), MIN (Charges) FROM CABHUB;

(iii) SELECT COUNT (*) Make FROM CABHUB;

(iv) SELECT Vehicle FROM CABHUB WHERE Capacity=4;


ANSWERS

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.

(i) To display details of all transactions of TYPE Deposit from Table


TRANSACT. 

(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');

  (vi) SELECT DISTINCT ANO FROM TRANSACT; 

(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

ANO ANAME ADDRESS


101 Niraja Singh Bangalore
102 Rohan Gupta Chennai
103 Ali Reza Hyderabad
104 Rishabh Jain Chennai
105 Simran Kaur Chandigarh

TABLE: TRANSACT

TRNO ANO AMOUNT TYPE DOT


T001 101 2500 Withdraw 2017-12-12
T002 103 3000 Deposit 2017-06-01
T003 102 2000 Withdraw 2017-05-12
T004 103 1000 Deposit 2017-10-22
T005 101 12000 Deposit 2017-11-06
ANSWERS

(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

CODE BNAME TYPE


F101 The Priest Fiction
L102 German Easy Literature
C101 Tarzan in the lost world Comic
F102 Untold Story Fiction
C102 War Heroes Comic
TABLE: MEMBER
MNO MNAME CODE ISSUEDATE
M101 RAGHAV SINHA L102 2016-10-13
M103 SARTHAK JOHN F102 2017-02-23
M102 ANISHA KHAN C101 2016-06-12
ANSWERS

(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

1. To display the details of all the products in ascending order of product


names (i.e., PNAME).

2. To display product name and price of all those products, whose price is in
the range of 10000 and 15000 (both values inclusive).

3. To display the number of products, which are supplied by each supplier


i.e., the expected output should be; S01 2 S02 2 S03 1

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

ITCODE ITEMTYPE TURNOVER


15 STATIONARY 3400000
17 HOSEIRY 6500000
12 BAKERY 10090000

TABLE : SALESPERSON

CODE NAME SALARY ITCODE


1001 TANDEEP JHA 60000 12
1002 YOGRAJ SINHA 70000 15
1003 TENZIN JACK 45000 12
1004 ANOKHI RAJ 50000 17
1005 TARANA SEN 55000 17

(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)

(iv) SELECT MAX(SALARY) FROM SALESPERSON;

(iv) SELECT DISTINCT ITCODE FROM SALESPERSON;


(v) SELECT CODE, NAME, I. ITCODE FROM SALESPERSON S, ITEM I WHERE S.
ITCODE=I.ITCODE AND TURNOVER>=700000;
(vi) SELECT SUM(SALARY) FROM SALESPERSON WHERE ITCODE=” I2”;
ANSWERS

(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.

(i) TO DISPLAY ENO, NAME, GENDER FROM THE TABLE EMPLOYEE IN


ASCENDING ORDER OF ENO.
(ii) TO DISPLAY THE NAME OF ALL THE MALE EMPLOYEES FROM THE TABLE
EMPLOYEE.
(iii) TO DISPLAY THE ENO AND NAME OF THOSE EMPLOYEES FROM THE TABLE
EMPLOYEE WHO ARE BORN BETWEEN ‘1987-01-01’ AND ‘1991-12-01’.

(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;

(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;

(viii) SELECT NAME, DEPARTMENT FROM EMPLOYEE E, DEPT D WHERE E.


DCODE=D.DCODE AND ENO<1003;

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

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)

You might also like