CBSE QUESTION BANK (2011 17)
[Question wise & Year wise Collection of Questions from CBSE s AISSCE Question Paper (2011 2017)]
Compiled By:-Jitendra
Jitendra Kumar Sinha,TGT(IT)DAV CRRC (Medical Unit),Cherki Road Gaya.
M
(a) Q. What is the purpose of ALTR TABLE command in MySql? How is it different from UPDATE 2
command?
A. ALTER TABLE command is used to modify the structure of a table.
ALTER TABLE UPDATE
It is a DDL command. It is a DML command
Changes the underlying table Changes values of tuples in a
Cannot be rolled back Can be rolled back
(b) Q. Table employee has 4 records and Table Dept has 3 records in it. Mr. Jain wants to display 1
all information stored in both of these related tables. He forgot to specify equi join
condition in the query. How many rows will get displayed on execution of this query?
A. 12
(c) Q. Consider the table EXAM given below. Write commands in MySql for(i) to (iv) and 7
output for (v) to (vii)
Table: EXAM
No Name Stipend Subject Average Division
1 Karan 400 English 68 FIRST
2 Aman 680 Mathematics 72 FIRST
3 Javed 500 Accounts 67 FIRST
4 Bishakh 200 Informatics 55 SECOND
5 Sugandha 400 History 35 THIRD
6 Suparna 550 Geography 45 THIRD
(i) To list the names of those students, who have obtained Division as FIRST in the
ascending order of NAME.
(ii) To display a report listing NAME, SUBJECT and Annual stipend received assuming that
the stipend column has monthly stipend.
(iii) To count the number of students, who have either accounts or informatics as
subject.
(iv) To insert a new row in the table EXAM: 6, Mohan ,500, English ,73, Second
(v) SELECT AVG(Stipend) FROM EXAM WHERE DIVISION= THIRD
(vi) SELECT COUNT(DISTINCT Subject) FROM EXAM;
(vii) SELECT MIN(Average) FROM EXAM WHERE Subject= English ;
A. (i) SELECT Name FROM Exam WHERE Division = 'FIRST' ORDER BY Name;
(ii) SELECT NAME, SUBJECT, STIPEND * 12 AS Annual Stipend FROM EXAM;
(iii) SELECT COUNT(*) FROM EXAM WHERE SUBJECT IN ('Accounts', 'Informatics') ;
(iv) INSERT INTO EXAM VALUES (6, Mohan , 500, English , 73, SECOND );
(v) 475
(vi) 6
(vii) 68
CBSE Question Bank with Solutions Class XII (IP) 42 | P a g e
M
(a) Q. What is the purpose of ORDER BY clause in MySql? How is it different from GROUP BY 2
clause?
A. Order by clause is used to sort the query result on a particular field in either ascending
order or descending order.
Difference:
ORDER BY is used to sort the result in specified columns name whereas GROUP BY is
used to group query result based on specified group attribute(s).
(b) Q. Table SCHOOL has 4 rows and 5 columns. What is the Cardinality and Degree of this 1
table?
A. Cardinality = 4 and Degree = 5
(c) Q. Consider the Table SHOPPE given below. Write command in MySql for (i) to (iv) and 7
output for (v) to (vii)
(i) To display names of the items whose name starts with C in ascending order of
Price.
(ii) To display code, Item name and City of the products whose quantity is less than
100.
(iii) To count distinct Company from the table.
(iv) To insert a new row in the table Shoppe
110 , Pizza , Papa Jo
ones , 120, Kolkata , 50.0
(v) Select Item from Shoppe where Item IN ( Jam , Coffee );
(vi) Select Count(distinct(City)) from Shoppe;
(vii) Select MIN(Qty) from Shoppe where City= Mumbai ;
A. (i) SELECT Item FROM SHOPPE WHERE Item LIKE 'c%' ORDER BY Price;
(ii) SELECT Code,Item,City FROM SHOPPE WHERE Qty < 100;
(iii) SELECT COUNT (DISTINCT(Company)) FROM SHOPPE;
(iv) INSERT INTO SHOPPE PE VALUES (110,'Pizza' , Papa Jones ,120,'kolkata' ,5
50.0);
(v) Item
Jam
Cofee
(vi) Count(distinct(city))
3
(vii) Min(Qty)
56
CBSE Question Bank with Solutions Class XII (IP) 43
3|Page
M
(a) Q. What is the use of COMMIT statement in SQL? How is it different from ROLLBACK 2
statement?
A. The COMMIT statement is used to save all changes made to the database while ROLLBACK
statement is used to UNDO changes made to the database.
(b) Q. Mr. James created a table CLIENT with 2 rows and 4 columns. He added 2 more rows to it 1
and deleted one column. What is the Cardinality and Degree of the Table CLIENT?
CLIENT
A. Cardinality 4 and Degree 3
(c) Q. Consider the following table FITNESS with details about fitness products being sold in the 7
store. Write command of SQL for (i) to (iv) and output for (v) to (vii).
Table: FITNESS
PCODE PNAME PRICE MANUFACTURER
P1 Treadmill 21000 Coscore
P2 Bike 20000 Aone
P3 Cross Trainer 14000 Reliable
P4 Multi Gym 34000 Coscore
P5 Massage chair 5500 Regrosene
P6 Belly Vibrator Belt 6500 Ambaway
(i) To display the names of all the products with price more than 20000.
(ii) To display the names of all products by the manufacturer Aone .
(iii) To change the price data of all the products by applying 25% discount reduction.
(iv) To add a new row for product with the details:
P7 , Vibro Exerciser , 28000, Aone .
(v) SELECT * FROM FITNESS WHERE MANUFACTURER NAME LIKE %e ;
(vi) SELECT COUNT (DISTINCT (MANUFACTURER)) FROM FITNESS;
(vii) SELECT MAX (PRICE) FROM FITNESS;
A. (i) SELECT PNAME,PRICE FROM FITNESS WHERE PRICE>20000;
(ii) SELECT PNAME FROM FITNESS WHERE MANUFACTURER="Aone";
(iii) UPDATE FITNESS SET PRICE=PRICE (PRICE*25/100);
(iv) INSERT INTO FITNESS VALUES("P7","Vibro Exerciser","28000","Aone");
(v) In this query, the column name is MANUFACTURER NAME instead of
MANUFACTURE so it will generate an error.
The correct Query is SELECT * FROM FITNESS WHERE MANUFACTURER LIKE %e ;
Output:
(vi) COUNT(DISTINCT(MANUFACTURER))
5
CBSE Question Bank with Solutions Class XII (IP) 44
4|Page
(vii) MAX(PRICE)
34000
M
(a) Q. What is the difference between % and _ wild card character with reference to LIKE 2
clause of MySQL?
A. % is used to represent any sequence of Zero or more characters wheras
_ is used to represent a single character.
(b) Q. Name a function of MySQL used to give the first occurance of a string2 in string1. 1
A. INSTR()
(C) Q. Consider the following table names EXAM with details of marks. Rite command of MySQl 7
for (i) to (IV) and Output for (v) to (Vii).
Table : EXAM
Adno SName Percentage Clsection Stream
R001 Sushant 90.2 12A Science
R002 Vaidyanath 80.5 12B Humanities
R003 Miara 68.9 12B Science
R004 Niara 96.0 12A Commerce
R005 Shinjini 88.9 12D Commerce
(i) To display all information of the students of humanities in descending order of
percentage.
(ii) To display Adno, Name, Percentage and Stream of those students whose name is
less than 6 characters long.
(iii) To add another column Bus)Fees with datatype and size as decimal (8,2).
(iv) To increase percentage by 2% of all the humanities students.
(v) SELECT COUNT(*) FROM EXAM;
(vi) SELECT
ELECT Sname, Percentage FROM EXAM WHERE Name LIKE N% ;
(vii) SELECT ROUND(Percentage,0) FROM EXAM WHERE Adno= R005 ;
A. (i) SELECT * FROM EXAM WHERE Stream= Humani es ORDER BY Percentage DESC;
(ii) SELECT Adno,SName,Percentage, Stream FROM EXAM WHERE
LENGTH(SName)<6;
(iii) ALTER TABLE EXAM ADD (Bus_Fees DECIMAL (8,2));
(iv) UPDATE EXAM Set percentage =Percentage +(Percentage *0.02)
(v) Where Stream = H Humanities ;
(vi) 5
(vii) Niara 96.0
(viii) 89
M
(a) Q. Distinguish between Single Row and Aggregate functions of MySQL. Write one 2
example of each.
A. Single row functions are applied to each row of the table whereas Aggregate functions
are applied on whole values of a column.
Example: Single Row function le (), right () etc.
Aggregate function Sum(), Min() etc.
CBSE Question Bank with Solutions Class XII (IP) 45
5|Page
(b) Q. Consider the following table named SOFTDRINK . Write commands of SQL for (i) to 7
(iv) and output for (v) to (vii).
Table: SOFTDRINK
DRINKCODE DNAME PRICE CALORIES
101 Lime and Lemon 20.00 120
102 Apple Drink 18.00 120
103 Nature Nectar 15.00 115
104 Green Mango 15.00 140
105 Aam Panna 20.00 135
106 Mango Juice Bahar 12.00 150
(i) To display names and drink codes of those drinks those have more than 120
calories.
(ii) To display drink codes, names and calories of all drinks, in descending order of
calories.
(iii) To display names and price of drinks that have price in the range 12 to 18 (both 12
and 18 included)
(iv) Increase the price of all drinks in the given table by 10%.
(v) SELECT COUNT(DISTINCT(PRICE)) FROM SOFTDRINK;
(vi) SELECT MAX (CALORIES) FROM SOFTDRINK;
(vii) SELECT DNAME FROM SOFTDRINK WHERE DNAME LIKE %Mango% ;
A. (i) Select DNAME, DRINKCODE from SOFTDRINK where CALORIES>120;
(ii) Select DRINKCODE,DNAME, CALORIES from SOFTDRINK order by CALORIES desc;
(iii) Select DNAME, PRICE from SOFTDRINK where CALORIES >= 12 and CALORIES<=18;
(iv) Update SOFTDRINK set PRICE=PRICE+ (PRICE*10/100);
(v) 4
(vi) 150
(vii) Green Mango
Mango Juice Bahar
(c) Q. What is the degree and ccardinality of SOFTDRINK Table ? 1
A. Degree 4 and cardinality 6
M
(a) Q. Srishti has created the folllowing table with the name Veterinary . 2
One of the rows inserted is as follows :
(i) What are the data type of columns AnimalId and VacinnationDate in the table
Veterinary ?
(ii) Srishti is now trying to insert the following row
CBSE Question Bank with Solutions Class XII (IP) 46
6|Page
Will she be able to successfully insert it? Give reason.
A. (i) Data type of AnimalId : Varchar/char
Data type of VaccinationDate : Date
(ii) No
Reason Not Null Constraint applied on a ribute AnimalName
(b) Q. Write the output of the following query. 2
(i) SELECTMID('LearningIsFun',2,4)
(ii) SELECTROUND(76.384,2)
(iii) SELECTINSTR('INFORMATIONFORM','RM')
(iv) SELECTDAYOFYEAR('2015 01 30')
A. (i) MID('LearningIsFun',2,4)
earn
(ii) ROUND(76.384,2)
76.38
(iii) I NSTR('INFORMATION FORM','RM')
5
(iv) DAYOFYEAR('2015 01 30')
30
(c) Q. Table Order is shown below. Write commands in SQL for (i) to (iv)and 6
output for (v) and (vi)
(i) To display names of Salespersons (without duplicates).
(ii) To list Orderid and respective Order amount in descending order of order amount.
(iii) To count the number of orders booked by Salespersons with names starrting with R
(iv) To list Order ids, order dates and order amounts that were booked after 1 st
September 2015.
(v) SELECTOrderId,OrderDate,OrderAmount FROM Order
WHERE OrderDate > 22015 09 01
(vi) SELECT OrderId, OrderAmount FROM Order
where OrderAmount between 50000 and 60000
A. (i) SELECT DISTINCT SalesPerson FROM Order
(ii) SELECTOrderId,OrderAmount FROM Order ORDER BY OrderAmount desc
(iii) SELECT COUNT(*) FROM Order WHERE SalesPerson LIKE R%
(iv) SELECTOrderId, OrderDate, OrderAmount FROM Order
WHERE OrderDate > 22015 09 01
CBSE Question Bank with Solutions Class XII (IP) 47
7|Page
(v)
(vi)
M
(a) Q. Consider the Table Infant shown below. 10
Table: Infant
NOTE : Discount column stores discount %.
Write the commands in SQL for (i) to (viii) and output for (ix) and (x)
(i) To display the details about the Cot.
(ii) To list the names of items and their unit price that have unit price less than 800
and discount more than 5%.
(iii) To list the names of items and their date of purchase that were purchased after
31st December , 2015.
(iv) To display the number of items that have mormore than 10% as discount
(v) To display Item code and unit price in decreasing order of unit price.
(vi) To increase the Unit price of each item by 10% of their unit price.
(vii) To display the highest unit price of items.
(viii) To display the names
mes of items that have Baby anywhere in their item em names
(ix) SELECT MID(Item,1,2) FROM Infant;
(x) SELECT AVG(UnitP Price)FROM Infant WHERE DATEPURCHASE > 2015 01 01 ;
CBSE Question Bank with Solutions Class XII (IP) 48
8|Page
NOTE : Discount column stores discount %.
Write the commands in SQL for (i) to (viii) and output for (ix) and (x)
A. (i) SELECT * FROM Infant WHERE Item= Cot ;
(ii) SELECT Item, UnitPrice FROM Infant WHERE UnitPrice < 800 AND Discount > 5;
(iii) SELECT Item, DatePurchase FROM Infant WHEREDatePurchase> 2015 12 31 ;
(iv) SELECT COUNT(Item) FROM Infant WHERE Discount > 10;
(v) SELECT ItemCODE, UnitPrice FROM Infant ORDER BY UnitPrice DESC;
(vi) UPDATE Infant SET UnitPrice = UnitPrice + (UnitPrice * 10/100);
(vii) SELECTMAX(UnitPrice) FROM Infant;
(viii) SELECT Item FROM Infant WHERE Item LIKE %Baby% ;
(ix) M ID(Item,1,2)
Fr
Co
So
Ba
Ba
(x) AVG(UnitPrice)
1750.0
CBSE Question Bank with Solutions Class XII (IP) 49 | P a g e