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

RDBMS File

Uploaded by

Pratyush paul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

RDBMS File

Uploaded by

Pratyush paul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Date :______________

Question 1. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii) which
are based on tables

(i) To display details of all transactions of TYPE Withdraw from TRANSACT table
(ii) To display ANO and AMOUNT of all Deposit and Withdrawals done in month of „May‟
2017 from table TRANSACT
(iii) To display first date of transaction (DOT) from table TRANSACT for Account having
ANO as 102
(iv) To display ANO, ANAME, AMOUNT and DOT of those persons from ACCOUNT and
TRANSACT table who have done transaction 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 DOT <= '2017-10-01'

Page no:
Date :______________

Question 2. Consider the following tables EMP and SALGRADE, write the query for (i) to (vi)
and output for (vii) to (x).

(i) To display details of all employee in descending order of their DOJ


(ii) To display NAME AND DESIG of those employees whose sgrade is either “S02” or
“S03”
(iii) To display NAME, DESIG, SGRADE of those employee who joined in the year 2009
(iv) To display all SGRADE, ANNUAL_SALARY from table SALGRADE [where
ANNUAL_SALARY = SALARY*12]
(v) To display number of employee working in each SALGRADE from table EMPLOYEE
(vi) To display NAME, DESIG, SALARY, HRA from tables EMPLOYEE and SALGRADE
where SALARY is less than 50000
(vii) Select MIN(DOJ), MAX(DOB) from employee;
(viii) Select SGrade,Salary+HRA from SalGrade where Sgrade=‟S02‟
(ix) Select count(distinct sgrade) from employee
(x) Select sum(salary), avg(salary) from salgrade

Page no:
Date :______________

Question 3. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii) which
are based on tables

(i) To display details of all Trains which starts from New Delhi
(ii) To display PNR, PNAME, GENDER and AGE of all passengers whose AGE is below 50
(iii) To display total numbers of MALE and FEMALE passengers

Page no:
Date :______________

(iv) To display records of all passengers travelling in trains whose TNO is 12015
(v) SELECT MAX(TRAVELDATE),MIN(TRAVELDATE) FROM PASSENGERS WHERE
GENDER=‟FEMALE‟;
(vi) SELECT END, COUNT(*) FROM TRAINS GROUP BY END HAVING COUNT(*)>1;
(vii) SELECT DISTINCT TRAVELDATE FROM PASSENGERS;
(viii) SELECT TNAME, PNAME FROM TRAINS T, PASSENGERS P WHERE T.TNO=P.TNO AND
AGE BETWEEN 50 AND 60

Page no:
Date :______________

Question 4. Consider the table SHOPPE and ACCESSORIES, write the query for (i) to (v) and
output for (vi) to (x)

(i) To display Name and Price of all the Accessories in descending order of their Price
(ii) To display Id and Sname of all the Shoppe location in “Nehru Place”
(iii) To display Name, Minimum and Maximum Price of each Name from ACCESSORIES
table
(iv) To display Name, Price of all Accessories and their respective SName from table
SHOPPE and ACCESSORIES where Price is 5000 or more.
(v) To display all details of accessories where name contains word “Board”;
(vi) SELECT DISTINCT NAME FROM ACCESSORIES WHERE PRICE>5000;
(vii) SELECT AREA,COUNT(*) FROM SHOPPE GROUP BY AREA;
(viii) SELECT AVG(PRICE), MAX(PRICE) FROM ACCESSORIES WHERE PRICE>=10000;
(ix) SELECT NAME, PRICE*.05 DISCOUNT FROM ACCESSORIES WHERE ID IN (“S02”,
“S03”)
(x) SELECT * FROM SHOPPE S, ACCESSORIES A WHERE S.ID = A.ID AND PRICE>=10000;

Page no:
Date :______________

Question 5. Considering the Visitor table data, write the query for (i) to (iv) and output for (v)
to (viii)

Table: Visitor

(i) Write a query to display VisitorName, Coming From details of Female Visitors with
Amount Paid more than 3000
(ii) Write a query to display all coming from location uniquely
(iii) Write a query to insert the following values-
7, “Shilpa”, ‟F”, ‟Lucknow”, 3000
(iv) Write a query to display all details of visitors in order of their AmountPaid from
highest to lowest
(v) Select VisitorName from Visitor where Gender=‟M‟;
(vi) Select AmountPaid+200 from Visitor where VisitorID=6;
(vii) Select Sum(AmountPaid) from Visitor where comingFrom=‟Kanpur‟;
(viii) Select Count(VisitorName) from Visitor where AmountPaid is NULL;

Page no:
Date :______________

Question 6. In a database there are two tables :

Write the MySQL queries for the following :

(i) To display PatID, PatName, and corresponding DocName of “Cardio‟ and “Ortho”
patient
(ii) To display DocName, PatName of those patient who are admitted before 15-Oct
2013

Page no:
Date :______________

Question 7. Write Query for the following requirements.

(i) TO DISPLAY THE NAME OF STUDENT , SUBJECT AND ADVISOR NAME


(ii) TO DISPLAY THE STUDENT NAME AND ADVISOR ALL THE STUDENTS WHO ARE
OFFERING EITHER PHYSICS OR CHEMISTRY

Page no:
Date :______________

Page no:
Date :______________

Page no:

You might also like