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

SQL- Revision Questions

The document is a practice test for a Computer Science course focused on RDBMS and SQL. It includes various SQL query writing tasks, error identification, and differences between SQL commands. The test covers topics such as querying employee data, transaction records, and understanding SQL commands like DELETE, UPDATE, and JOINs.

Uploaded by

karthikeyan 5137
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)
19 views

SQL- Revision Questions

The document is a practice test for a Computer Science course focused on RDBMS and SQL. It includes various SQL query writing tasks, error identification, and differences between SQL commands. The test covers topics such as querying employee data, transaction records, and understanding SQL commands like DELETE, UPDATE, and JOINs.

Uploaded by

karthikeyan 5137
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/ 4

DATE: 03-07-2024 XII CS PRACTICE TEST

CH -7 RDBMS & STRUCTURED QUERY LANGUAGE

1 Mr. Raj is a database programmer, He has to write the query from


EMPLOYEE table to search for the employee whose name begins
from letter “R”, for this he has written the query as:
SELECT * FROM EMPLOYEE WHERE NAME=‟R%”;
But the query is not producing the correct output, help Raj and correct
the query so that he gets the desired output.
2 Mr. Mahesh is a database programmer, He has to write the query from
EMPLOYEE table to search for the employee who are not getting any
commission, for this he has written the query as:
SELECT * FROM EMPLOYEE WHERE commission=null;
But the query is not producing the correct output, help Raj and correct
the query so that he gets the desired output.
3 Ms. Sheela is a database programmer, has to write the query from
EMPLOYEE table to search for the employee who are working in „Sales‟
or „IT‟ department, for this he has written the query as: SELECT * FROM
EMPLOYEE WHERE department=‟Sales‟ or „IT‟;
But the query is not producing the correct output, help Raj and correct
the query so that he gets the desired output.
4 The following query is producing an error. Identify the error and also
write the correct query. SELECT * FROM EMP ORDER BY NAME
WHERE SALARY>=5000;
5 If Table Sales contains 5 records and Raj executed the following
queries; find out the output of both the query.
(i) Select 100+200 from dual;
(ii) Select 100+200 from Sales;
6 What is the difference between Equi-Join and Natural Join?
7 Observe the given Table TEACHER and give the output of question (i)
and (ii)
TEACHER_COD TEACHER_NAM DOJ
E E
T001 ANAND 2001-01-30
T002 AMIT 2007-09-05
T003 ANKIT 2007-09-20
T004 BALBIR 2010-02-15
T005 JASBIR 2011-01-20
T006 KULBIR 2008-07-11
(i) i)SELECT TEACHER_NAME,DOJ FROM TEACHER WHERE
TEACHER_NAME LIKE “%I%”
ii)SELECT * FROM TEACHER WHERE DOJ LIKE “%-09-%”;
8 Query to delete all record of table without deleting the table:
a. DELETE TABLE TABLE_NAME
b. DELETE FROM TABLE_NAME
c. DROP TABLE TABLE_NAME
d. DELETE TABLE FROM TABLE_NAME
9 Identify the wrong statement about UPDATE command
a. If WHERE clause is missing all the record in table will be updated
b. Only one record can be updated at a time using WHERE clause
c. Multiple records can be updated at a time using WHERE clause
d. None of the above
10 Suppose a table BOOK contain columns (BNO, BNAME, AUTHOR,
PUBLISHER), Raj is assigned a task to see the list of publishers,
when he executed the query as:
SELECT PUBLISHER FROM BOOK;
He noticed that the same publisher name is repeated in query output.
What could be possible solution to get publisher name uniquely?
Rewrite the following query to fetch unique publisher names from table.
11 Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii) which
are based on tables

TABLE: TRANSACT
TRNO ANO AMOUNT TYPE DOT
T001 101 2500 Withdraw 2017-12-21
T002 103 3000 Deposit 2017-06-01
T003 102 2000 Withdraw 2017-05-12
T004 103 1000 Deposit 2017-10-22
T005 102 12000 Deposit 2017-11-06
(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'

12 Consider the following tables EMP and SALGRADE, write the query for
(i) to (vi) and output for (vii) to (x)
TABLE: EMPLOYEE
ECODE NAME DESIG SGRAD DOJ DOB
E
101 Vikrant Executive S03 2003-03-23 1980-01-13
102 Ravi Head-IT S02 2010-02-12 1987-07-22
103 John Receptio S03 2009-06-24 1983-02-24
n
105 Azhar GM S02 2009-08-11 1984-03-03
108 Priyam CEO S01 2004-12-29 1982-01-19
TABLE: SALGRADE
SGRADE SALARY HRA
S01 56000 18000
S02 32000 12000
S03 24000 8000
(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 ANUAL_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
13 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 RICE>=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;
14 a) In a database there are two tables : Write MYSQL queries for (i) to (iii)
Table : Item
ICode IName Price Color VCode
S001 Mobile Phones 30000 Silver P01
S002 Refrigerator 20000 Cherry P02
S003 TV 45000 Black P03
S004 Washing 12000 White P04
Machine
S005 Air Conditioner 50000 White P05
Table : Vendor
VCode VName
P01 Rahu
l
P02 Mukesh
P03 Rohan
P04 Kapil
(i) To display ICode,IName and VName of all the vendors,who
manufacturer r efrigerator.
(ii) To display IName, ICode, VName and price of all the products whose
price >=23000
(iii) To display Vname and IName manufactured by vendor whose code is
“P04”.
15 What is the Difference between ALTER Table command and UPDATE
command?
16 (i) Sanjay was deleting the record of empno=1234, but at the time of
execution of command he forgot to add condition empno=1234, what
will be the effect of delete command in this case?
(ii) Sameer is executing the query to fetch the records of employee
who are getting salary between 4000 to 8000, he executed the query
as -Select * from Employee where salary between 4000 to 8000; But he
is not getting the correct output, Rewrite the c orrect query.
17 Sunil decides to delete a PhoneNo column from a MySQL Table
(student) after insert the data into the table. Write the command to
delete that particular column in student table.
18 A table Employee contains 5 Rows and 4 Columns and another table
PROJECT contains 5 Rows and 3 Columns. How many rows and
columns will be there if we obtain Cartesian product of these two
tables?
19 Ranjeet created a table named student, He wants to see those students
whose name ending with p. He wrote a query-
SELECT * FROM student WHERE name=”p%”;
But the query is not producing the desired output, Help Ranjeet to run
the query by removing the errors from the query and rewriting it.
20 DIFFERENCE BETWEEN
1. HAVING AND WHERE
2. % AND _ (Underscore)
3. CHAR AND VARCHAR

You might also like