Sie sind auf Seite 1von 8

DELHI PUBLIC SCHOOL

HIGH ORDER THINKING QUESTIONS FOR CLASS XII


ASSIGNMENTS SQL -COMP SC
Q1.
Table : SchoolBus
Rtno Area_overed
Capacity
Noofstudents
Distance
Transporter
Charges
1
Vasant kunj
100
120
10
Shivamtravels
100000
2
Hauz Khas
80
80
10
Anand travels
85000
3
Pitampura
60
55
30
Anand travels
60000
4
Rohini
100
90
35
Anand travels
100000
5
Yamuna Vihar
50
60
20
Bhalla Co.
55000
6
Krishna Nagar
70
80
30
Yadav Co.
80000
7
Vasundhara
100
110
20
Yadav Co.
100000
8
Paschim Vihar
40
40
20
Speed travels
55000
9
Saket
120
120
10
Speed travels
100000
10
Jank Puri
100
100
20
Kisan Tours
95000
(b) To show all information of students where capacity is more than the no of student in order of rtno.
(c) To show area_covered for buses covering more than 20 km., but charges less then 80000.
(d) To show transporter wise total no. of students traveling.
(e) To show rtno, area_covered and average cost per student for all routes where average cost per student is charges/noofstudents.
(f) Add a new record with following data:
(11, Moti bagh,35,32,10, kisan tours , 35000)
(g) Give the output considering the original relation as given:
(i) select sum(distance) from schoolbus where transporter= Yadav travels;
(ii) select min(noofstudents) from schoolbus;
(iii) select avg(charges) from schoolbus where transporter= Anand travels;
(iv) select distinct transporter from schoolbus;
Q2.
TABLE : GRADUATE
S.NO
NAME
STIPEND
SUBJECT
AVERAGE
DIV.
1
KARAN
400
PHYSICS
68
I
2
DIWAKAR
450
COMP. Sc.
68
I
3
DIVYA
300
CHEMISTRY
62
I
4
REKHA
350
PHYSICS
63
I
5
ARJUN
500
MATHS
70
I
6
SABINA
400
CEHMISTRY
55
II
7
JOHN
250
PHYSICS
64
I
8
ROBERT
450
MATHS
68
I
9
RUBINA
500
COMP. Sc.
62
I
10
VIKAS
400
MATHS
57
II
List the names of those students who have obtained DIV 1 sorted by NAME.
(b)
Display a report, listing NAME, STIPEND, SUBJECT and amount of stipend
received in a year assuming that the STIPEND is paid every month.
To count the number of students who are either PHYSICS or COMPUTER SC graduates.
To insert a new row in the GRADUATE table:
11,KAJOL, 300, computer sc, 75, 1
(e) Give the output of following sql statement based on table GRADUATE:
(i)
Select MIN(AVERAGE) from GRADUATE where SUBJECT=PHYSICS;
(ii)
Select SUM(STIPEND) from GRADUATE WHERE div=2;
(iii) Select AVG(STIPEND) from GRADUATE where AVERAGE>=65;
(iv)
Select COUNT(distinct SUBDJECT) from GRADUATE;

Q3. Write SQL command for (i) to (vii) on the basis of the table SPORTS

Table: SPORTS
Student NO
10
11
12
13
14
15

Class
7
8
7
7
9
10

Name
Sammer
Sujit
Kamal
Venna
Archana
Arpit

Game1
Cricket
Tennis
Swimming
Tennis
Basketball
Cricket

Grade
B
A
B
C
A
A

Game2
Swimming
Skating
Football
Tennis
Cricket
Atheletics

Grade2
A
C
B
A
A
C

(a)
Display the names of the students who have grade C in either Game1 or Game2 or both.
(b)
Display the number of students getting grade A in Cricket.
(c)
Display the names of the students who have same game for both Game1 and Game2.
(d) Display the games taken up by the students, whose name starts with A.
(e)
Assign a value 200 for Marks for all those who are getting grade B or grade A in both Game1
and
Game2.
(f)
Arrange the whole table in the alphabetical order of Name.
(g)
Add a new column named Marks.
Q4.
Empid
010
105
152
215
244
300
335
400
441
Empid
010
105
152
215
244
300
335
400
441

Firstname
Ravi
Harry
Sam
Sarah
Manila
Robert
Ritu
Rachel
Peter
Salary
75000
65000
80000
75000
50000
45000
40000
32000
28000

Employees
Lastname
Kumar
Waltor
Tones
Ackerman
Sengupta
Samuel
Tondon
Lee
Thompson
EmpSalary

Address
Raj nagar
Gandhi nagar
33 Elm St.
440 U.S. 110
24 Friends street
9 Fifth Cross
Shastri Nagar
121 Harrison St.
11 Red Road
Benefits
15000
15000
25000
12500
12000
10000
10000
7500
7500

City
GZB
GZB
Paris
Upton
New Delhi
Washington
GZB
New York
Paris

Designation
Manager
Manager
Director
Manager
Clerk
Clerk
Clerk
Salesman
salesman

Write the SQL commands for the following :


(i)
To show firstname,lastname,address and city of all employees living in paris
(ii)
To display the content of Employees table in descending order of Firstname.
(iii)
To display the firstname,lastname and total salary of all managers from the tables Employee and empsalary ,
where total salary is calculated as salary+benefits.
(iv)
To display the maximum salary among managers and clerks from the table Empsalary.
Give the Output of following SQL commands:
(i)
Select firstname,salary from employees ,empsalary where designation = Salesman and
Employees.empid=Empsalary.empid;
(ii)
Select count(distinct designation) from empsalary;
(iii)
Select designation, sum(salary) from empsalary group by designation having count(*) >2;
(iv)
Select sum(benefits) from empsalary where designation =Clerk;
Q5. Consider the following table MOV and answer the queries given below:
NO.
TITLE
TYPE
RATING

STARS

QTY

PRICE

a)
b)
c)
d)

e)
f)
g)

1
2
3
4
5
6
7
8
9
10

Gone with the world


Friday the 13th
Top Gun
Splash
Independence day
Risky Business
Cocoon
Crocodile Dundee
101 Dalmatians
Tootsie

Drama
Horror
Drama
Comedy
Drama
Comedy
Scifi
Comedy
Comedy
Comedy

G
R
PG
PG13
R
R
PG
PG13
G
PG

Gable
Jason
Cruise
Hanks
Turner
Cruise
Ameche
Harris
Cruise
Hoffman

4
2
7
3
3
2
2
2
3
1

39.95
69.95
49.95
29.95
19.95
44.95
31.95
69.95
59.95
29.95

Find the total value of the movie cassettes available in the library.
Display a list of all movies with Price over 20 and sorted by price
Display all movies sorted by QTY in descending order.
Display a report listing movie number, current value and replacement value for each movie in the above
table. Calculate the replacement value for all movies as QTY*PRICE*1.15.
Count the number of movies where Rating is not G.
Insert a new movie in the MOV table. Fill all the columns with values.
Give the output of following SQL commands on the basis of table MOV.
Select AVG(Price) FROM MOV where Price<30;
Select MAX(Price) FROM MOV where Price>30;
Select SUM(Price*QTY) FROM MOV where QTY<4;
Select COUNT(distinct TYPE) FROM MOV
Q.7. Consider the following table MOV and answer the queries given below:
NO. ItemName
CostPerItem
Quantity
1
2
3
4
5
6
7

Computer
Printer
Scanner
Camera
Hub
UPS
Plotter
1.
2.
3.
4.
5.
6.
7.

60000
15000
18000
21000
8000
5000
25000

9
3
1
2
1
5
2

DateofPurchas
e
21/5/96
21/5/97
29/8/98
13/6/96
31/10/99
21/5/96
11/1/2000

Warranty
2
4
3
1
2
1
2

Operationa
l
7
2
1
2
1
4
2

to select the itemname purchased after 31/10/97.


to list the itemname, which are within the warranty period till present date.
to list the itemname in ascending order of the date of purchase where quantity is more than 3.
to display itemname,costperitem and quantity whose warranty is over.
to count the number of items whose cost is more than 10000.
to insert a new record in the Lab table with the following data:
8 VCR,10000,2,{2/2/2000},1,2
Give the output of the following SQL commands:
a. SELECT MIN(DISTINCT Quantity) FROM LAB;
b. SELECT MIN(WARENTY) FROM LAB WHERE Quantity=2;
c. SELECT SUM(Costperitem) FROM LAB WHERE Quantity>0;
d. SELECT AVG(Costperitem) FROM LAB WHERE Dateofpurchase<{1/1/99};

Q8. Write the SQL commands for the following on the basis of tables INTERIORS and NEWONES
Table: INTERORS
SNO
ITEMNAME
TYPE
DATEOFSTOCK
PRICE
1
Red Rose
Double Bed
23/02/02
32000
2
Soft Touch
Baby Cot
20/1//02
9000
3
Jerrys Home
Baby Cot
19/02/02
8500
4
Rough Wood
Office Table
01/01/02
20000
5
Comfort Zone
Double Bed
12/01/02
15000
6
Jerry Look
Baby Cot
24/02/02
7000
7
Lion King
Office Table
20/02/02
16000
8
Royal Tiger
Sofa
22/02/02
30000
9
Park Sitting
Sofa
13/12/01
9000

DISCOUNT
15
10
10
20
20
19
20
25
15

10

Dine Paradise

Dining Table

19/02/02

11000

15

Table: NEWONES
SNO ITEMNAME
TYPE
DATEOFSTOCK
PRICE
DISCOUNT
11
White Wood
Double Bed
23/02/02
20000
20
12
James 007
Sofa
20/02/03
15000
15
13
Tom Look
Baby Cot
21/02/03
7000
10
(i)
To list the ITEMNAME which are priced at more than 1000 from the INTERIORS table
(ii)
To list ITEMNAME and TYPE of those items, in which DATEOFSTOCK is before 22/01/02 from the
INTERIORS table in descending order of ITEMNAME
(iii)
To show all information about the sofas from the INTERIORS table
(iv)
To display ITEMNAME and DATEOF STOCK of those items in which the discount percentage is more than 15
from INTERIORS table
(v)
To count the number of items, whose type is Double Bed from INTERIORS table
(vi)
To insert a new row in the NEWONES table with the following data
14,True Indian, Office Table, 28/03/03,15000,20
c) Get the Output (Use the above table without inserting the record)
Select COUNT(distinct TYPE) from INTERIORS
Select AVE(DISCOUNT) from INTERIORS where TYPE=Baby Cot
Select SUM(Price) from INTERIORS where DATEOF STOCK<{12/02/02}
Select MAX(Price) from INTERIORS , NEWONES;
Q.9 Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to
(viii): on the basis of the table
BOOKS
Book_Id
Book_Name
Author_name
Publishers
Price
Type
F0001
The Tears
William Hopkins
First Publ.
750
Fiction
F0002
Thunderbolt
Anna Roberts
First Publ.
700
Fiction
T0001
MyFirstC++
Brain & Brooke
EPB
250
Text
T0002
C++Brain
A.W. Rossaine
TDH
325
Text
C0001
Fast Cook
Lata Kapoor
EPB
350
Cooker
y
ISSUED
Book_Id
Quantity_Issued
F0001
3
T0001
1
C0001
5
(a)
(b)
(c)
(d)
(e)
(f)
(g)

(v)

Quantity
10
5
10
5
8

To show Book name, Author name and Price of books of EPB Publishers.
To list the names from books of Fiction type.
To display the names and price of the books in descending order of their price.
To increase the price of all books of First Publ. Publishers by 50.
To display the Book_Id, Book_Name and Quantity_Issued for all books which have been issued. (The query will
require contents from both the tables.)
To insert a new row in the table Issued having the following data:
F0002, 4.
Give the output:
(i)
SELECT COUNT (DISTINCT Publishers) FROM Books;
(ii)
SELECT SUM(Price) FROM Books WHERE Quantity > 5;
(iii)
SELECT Book_Name, Author_Name FROM Books WHERE Price <500;
SELECT COUNT (*) FROM Books;

Q10.Given below following table OFFICE. Write SQL queries for (i)-(iv) and give output for (vi)-(viii).
Empno
Empname
Age
Department
Sex
B_Pay
1
Ankit
45
Comp.Sc.
M
10000
2
Sumit
32
History
M
6000
3
Suchitra
23
Maths
F
9000
4
Amit
25
Geography
M
5000
5
Ankita
26
Hindi
F
8500
6
Shurti
28
Comp.Sc.
F
7200
7
Rakesh
35
Hindi
M
5900

8
i)
ii)
iii)
iv)
v)
vi)
vii)
viii)
Q11.

Q12.

Priya
33
History
F
10500
Display details of all employees belonging to History and Geography department.
Display average age of employee department wise.
Display number of employees in each department where number of employees are more than equal to 2.
Display details of all female employee belonging to various departments except in Maths and History.
Display name and age of those employees getting basic pay between 6000 and 10000.
Outputs --Select sum(B_pay) from OFFICE;
Select count (*) from OFFICE where name like A%;
Select empname from OFFICE where age in (select max(age) from OFFICE);

(i) To display the names of all Senders from Mumbai


(ii) To display the RecID), SenderName, SenderAddress, RecName,
RecAddress for every Recipient
(iii) To display Recipient details in ascending order of RecName
(iv) To display number of Recipients from each city
(v) SELECT DISTINCT SenderCity FROM Sender;
(vi) SELECT A. SenderName, B.RecNameFROM Sender A, Recipient B WHERE A. SenderlD =
B.SenderlD AND B.RecCity = Mumbai;
(vii) SELECT RecName, RecAddress FROM RecipientWHERE RecCity NOT IN (Mumbai, Kolkata);
(viii) SELECT RecID, RecName FROM Recipient WHERE SenderID=MU02' ORSenderID=ND50';
Q14. Answer the following questions
a) What is the purpose of Create table and create view
Write SQL commands for (b) to (g) and outputs for (h)
of tables FURNITURE and ARRIVALS
[6+2=8]
TABLE : FURNITURE
No
ITEMNAME
TYPE
DATEOFSTOCK
1
White Lotus
Double Bed
23/02/02
2
Pink feather
Baby cot
20/01/02
3
Dolphin
Baby cot
19/02/02
4
Decent
Office table
01/01/02
5
Comfort zone
Double bed
12/01/02
6
Donald
Baby cot
24/02/02
7
Royal finish
Office table
20/02/02
8
Royal tiger
Sofa
22/02/02
9
Econo
Sofa
13/12/01
10
Eating paradise
Dining table
19/02/02
TABLE : ARRIVALS

commands?[2]
on the basis

PRICE
30000
7000
9500
25000
25000
6500
18000
31000
9500
11500

DISC
25
20
20
30
25
15
30
30
25
25

No
11
12
13

ITEMNAME
TYPE
DATEOFSTOCK
PRICE
DISC
Wood comfort
Double bed
23/03/03
25000
25
Old fox
Sofa
20/02/03
17000
20
Milky
Baby cot
21/02/03
7500
15
b) To show all information about the baby cots from the FURNITURE
table.
c) To list the ITEMNAME which are priced at more then 15000 from the
FURNITURE table.
d) To list ITEMNAME and the type of those items, in which DATEOFSTOCK
is before 22/01/02 from the FURNITURE table in descending order of
ITEMNAME.
e) To display ITEMNAME and DATEOFSTOCK of those items, in which the
DISC percentage is more then 25 from FURNITURE table.
f) To count the number of items, whose type is SOFA from FURNITURE
table?
g) To insert a new row in ARRIVAL table.
h) Give the output of the following SQL command.
a. SELECT COUNT (DISTINCT TYPE) FROM FURNITURE
b. SELECT MAX (DISCOUNT) FROM FURNITURE WHERE TYPE=Baby cot
c. SELECT AVG (DISCOUNT) FROM ARRIVALS WHERE TYPE=D. bed
d. SELECT SUM (PRICES) FROM FURNITURE WHERE
DATEOFSTOCK<{12/02/02}
Q15. (a)What do you understand by DDL and DML. Write at least two DDL and DML coomands.
2
(b) Consider the following tables Employee and salary. Write SQL commands for the statements (i) to (iv)
and give outputs for SQL queries (v) to (viii).
6
Table : Employee
Eid
Name
Deptid
Qualification
1
Deepali Gupta
101
MCA
2
Rajat Tyagi
101
BCA
3
Hari Mohan
102
B.A
4
Harry
102
M.A
5
Sumit Mittal
103
B.Tech
6
Jyoti
101
M.Tech
Table : Salary
Eid
Basic
DA
HRA
1
6000
2000
2300
2
2000
300
300
3
1000
300
300
4
1500
390
490
5
8000
900
900
6
10000
300
490
(i)
To show the name of employees department wise.
(ii)
To list the names of those employees only whose basic is greater than 3000.
(iii)
To print the net salary from salary table where as net salary is calculated as
basic+da+hra+bonus
(iv)
To increase the bonus of all employees with 200.
(v)
Select name from employee where eid=(select eid from salary where basic= (select
max(basic) from salary));
(vi)
select Avg(basic) from salary where bonus >40;
(vii) Select count(*) from employee where sex=F;

Sex
F
M
M
M
M
F
Bonus
200
30
40
30
80
89

(viii)

select name from employee where qualification like %Tech

2 marks theory questions


Q16. Define alternate key ,attribute , candidate keys, cardinality and degree of a table ,foreign key ,data independence, primary
key, relation , tuple, domain,Views , What is DDL and DML, CREATE TABLE AND CREATE VIEW, DROP TABLE AND
DROP VIEW,ALTER TABLE and UPDATE commands.

Das könnte Ihnen auch gefallen