Questions

5 Marks Each

🎯

Test yourself on this topic

16 questions · timed · auto-graded

Question 15 Marks
Consider the following DEPT and WORKER tables. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii): [Delhi 2015]

Table: DEPT

DCODE DEPARTMENT CITY
D01 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI

Table: WORKER

WNO NAME DOJ DOB GENDER DCODE
1001 George K 2013-09-02 1991-09-01 MALE D01
1002 Ryma Sen 2012-12-11 1990-12-15 FEMALE D03
1003 Mohitesh 2013-02-03 1987-09-04 MALE D05
1007 Anil Jha 2014-01-17 1984-10-19 MALE D04
1004 Manila Sahai 2012-12-09 1986-11-14 FEMALE D01
1005 R SAHAY 2013-11-18 1987-03-31 MALE D02
1006 Jaya Priya 2014-06-09 1985-06-23 FEMALE D05

Note: DOJ refers to date of joining and DOB refers to date of Birth of workers.

(i) To display Wno, Name, Gender from the table WORKER in descending order of Wno.

(ii) To display the Name of all the FEMALE workers from the table WORKER.

(iii) To display the Wno and Name of those workers from the table WORKER who are born between ‘1987-01-01’ and ‘1991-12-01’.

(iv) To count and display MALE workers who have joined after ‘1986-01-01’.

(v) SELECT COUNT(*), DCODE FROM WORKER GROUP BY DCODE HAVING COUNT(*)>1;

(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;

(vii) SELECT NAME, DEPARTMENT, CITY FROM WORKER W,DEPT D WHERE W.DCODE=D.DCODE AND WNO<1003;

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

View full question & answer
Question 25 Marks
Answer the (a) and (b) on the basis of the following tables STORE and ITEM: [Delhi 2014]

Table: STORE

SNo SName AREA
S01 ABC Computronics GK II
S02 All Infotech Media CP
S03 Tech Shoppe Nehru Place
S05 Hitech Tech Store CP

Table: ITEM

INo IName Price SNo
T01 Mother Board 12000 S01
T02 Hard Disk 5000 S01
T03 Keyboard 500 S02
T04 Mouse 300 S01
T05 Mother Board 13000 S02
T06 Key Board 400 S03
T07 LCD 6000 S04
T08 LCD 5500 S05
T09 Mouse 350 S05
T10 Hard disk 4500 S03

(a) Write the SQL queries (1 to 4):

(i) To display IName and Price of all the items in the ascending order of their Price.

(ii) To display the SNo and SName or all stores located in CP.

(iii) To display the minimum and maximum price of each IName from the table Item.

(iv) To display the IName, price of all items and their respective SName where they are available.

(b) Write the output of the following SQL commands (i) to (iv):

View full question & answer
Question 35 Marks
Consider the following tables CARHUB and CUSTOMER and answer (a) and (b) parts of this question: [Delhi 2012]

Table: CARHUB

Vcode Vehicle Name Make Color Capacity Charges
100 Innova Toyota WHITE 7 15
102 SX4 Suzuki BLUE 4 14
104 C Class Mercedes RED 4 35
105 A-Star Suzuki WHITE 3 14
108 Indigo Tata SILVER 3 12

Table: CUSTOMER

CCode CName VCode
1 Hemant Sahu 101
2 Raj Lal 108
3 Feroza Shah 105
4 Ketan Dhal 104

(a) Write SQL commands for the following statements:

(i) To display the names of all white colored vehicles

(ii) To display name of vehicle, make 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 CARHUB.

(iv) To display the customer name and the corresponding name of the vehicle hired by them.

(b) Give the output of the following SQL queries:

(i) Select count(distinct make) from cabhub;

(ii) Select max(charges), min(charges) from carhub;

(iii) Select count(*), make from carhub;

(iv) Select vehiclename from carhub where capacity = 4;

Answer
(a) (i) Select vehiclename from carhub where color = ‘white’;

(ii) Select vehiclename, make, capacity from carhub order by capacity;

(iii) Select max(charges) from carhub;

(iv) Select cname, vehiclename, from customer, carhub where customer.vcode = carhub. vcode;

(b)

View full question & answer
Question 45 Marks
Consider the following tables WORKER and PAYLEVEL and answer (a) and (b) parts of this question:


[Delhi 2011]

Relation: WORKER

ECODE NAME DESIG PAYLEVEL DOJ DOB
11 Radhey Shyam Supervisor P001 13-Sep-2004 23-Aug-1981
12 Chander Nath Operator P003 22-Feb-2010 12-Jul-1987
13 Fizza Operator P003 14-June-2009 14-Oct-1983
15 Ameen Ahmed Mechanic P002 21-Aug-2006 13-Mar-1984
18 Sanya Clerk P002 19-Dec-2005 09-June-1983

Relation: PAYLEVEL

PAYLEVEL PAY ALLOWANCE
P001 26000 12000
P002 22000 10000
P003 12000 6000

(a) Write SQL commands for the following statements:

(i) To display the details of all WORKERs in descending order of DOB.

(ii) To display NAME and DESIG of those WORKERs whose PLEVEL is either P001 or P002.

(iii) To display the content of all the WORKERs table, whose DOB is in between ’19-JAN-1984’ and ’18-JAN-1987’.

(iv) To add a new row with the following:

19, ‘Daya kishore’, ‘Operator’, ‘P003’, ’19-Jun-2008’, ’11-Jul-1984’

(b) Give the output of the following SQL queries:

View full question & answer
Question 55 Marks

Write SQL queries for (a) to (d) and find outputs for SQL queries (e) to (h), which are based on the tables. [CBSE Sample Paper 2017]

TABLE: WATCHES

Watchid Watch_name Price Type Qty_store
W001 High time 10000 Unisex 100
W002 Life time 15000 Ladies 150
W003 Wave 20000 Gents 200
W004 High fashion 7000 Unisex 250
W005 Golden time 25000 Gents 100

TABLE: SALE

Watchid Qty_Sold Quarter
W001 10 1
W003 5 1
W002 20 2
W003 10 2
W001 15 3
W002 20 3
W005 10 3
W003 15 4

(a) To display all the details of those watches whose name ends with ‘time’

(b) To display watch’s name and price of those watches which have price range between 5000-15000

(c) To display total quantity in store of unisex type watches

(d) To display watch name and their quantity sold in first quarter

(e) Select max(price),min(qty_store) from watches;

(f) Select quarter, sum(qty_sold) from sale group by quarter;

(g) Select watch_name,price,type from watches w, sale s where w.watchid=s.watchid;

(h) Select watch_name, qty_store, sum(qty_sold),qty_store

View full question & answer
Question 65 Marks
Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (vii), which are based on the tables. [CBSE Sample Paper 2018]

Table: Trainer

TID Tname City HireDate Salary
101 Sunaina Mumbai 1998-10-15 90000
102 Anamika Delhi 1994-12-24 80000
103 Deepti Chandigarh 2001-12-21 82000
104 Meenakshi Delhi 2002-12-25 78000
105 Richa Mumbai 1996-01-12 95000
106 Maniprabha Chennai 2001-12-12 69000

Table: Course

CID CNAME FEES STARTDATE TID
C201 AGDCA 12000 2018-07-02 101
C202 ADCA 15000 2018-07-15 103
C203 DCA 10000 2018-10-01 102
C203 DDTP 9000 2018-09-15 104
C205 DHN 20000 2018-08-01 101
C206 O LEVEL 18000 2018-07-25 105

(a) Display the Trainer Name, City and Salary in descending order of their hire date.

(b) To display the TNAME and CITY of Trainer of joined the institute in the month of December 2001.

(c) To display TNAME, HIREDATE,CNAME, STARTDATE from tables TRAINER and COURSE whose FEES is less than or equal to 10000

(d) To display number of trainer from each city (e) select tid, tname,from trainer where city not in(‘delhi’,’mumbai’);

(f) select distinct tid from course;

(g) select tid , count (*), min(fees) from course group by tid having count(*)>1;

(h) Select count(*),sum(fees) from course where startdate <’2018-09-15’;

View full question & answer
Question 75 Marks
Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables: [Delhi 2018(C)]

TABLE: SALESPERSON

CODE NAME SALARY ITCODE
1001 TANDEEP JHA 60000 I2
1002 YOGRAJ SINHA 70000 I5
1003 TENZIN JACK 45000 I2
1005 ANOKHI RAJ 50000 I7
1004 TARANA SEN 55000 I7

TABLE: ITEM

ITCODE ITEMTYPE TURNOVER
I5 STATIONARY 3400000
I7 HOISTERY 6500000
I2 BAKERY 10090000

(a) To display the CODE and NAME of all salesperson having “I7” item Type Code from the table SALESPERSON.

(b) To display all details from table SALESPERSON in descending order of SALARY.

(c) To display the number of SALESPERSON dealing in each TYPE of ITEM.(Use ITCODE for the same)

(d) To display NAME of all the salesperson table along with their corresponding ITEMTYPE from the ITEM table.

(e) Select max(salary) from salesperson;

(f) Select distinct itcode from salesperson;

(g) select code,name,i.itcode from sales person s, item i where s.itcode=i.itcode and turnover>=7000000;

(h) Select sum (salary)from salesperson where itcode=”i2”;

View full question & answer
Question 85 Marks
Write SOL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii) which are based on the tables. [Delhi 2019(C)]

TABLE : CUSTOMERS

NO CNAME ADDRESS
101 Richa jain Delhi
101 Surbhi Sinha Chennai
103 Lisa Thomas Bangalore
104 Imran Ali Delhi
105 Roshan Singh Chennai

TABLE : TRANSACTION

TRNO CNO AMOUNT TYPE DOT
T001 101 1500 Credit 2017-11-23
T002 103 2000 Debit 2017-05-12
T003 102 3000 Credit 2017-06-10
T004 103 12000 Credit 2017-09-12
T004 101 1000 Debit 2017-09-05

(a) To display details of all transactions of TYPE Credit from Table TRANSACTION.

(b) To display the CNO and AMOUNT of all transactions done in the month September 2017 from the table TRANSACTION.

(c) To display the last date of transaction (DOT) from the table TRANSACTION for the customer having CNO as 103.

(d) To display all CNO,CNAME and DOT (date of transaction) of those CUSTOMERS from tables CUSTOMERS and TRANSACTION who have done transactions more than or equal to 2000.

(e) Select count(*), avg(amount) from transaction where dot>= ‘2017-06-01’;

(f) Select cno, count(*), max (amount) from transaction group by cno having count(*)> 1;

(g) Select cno, cname from customer where address not in (‘Delhi, ‘Bangalore’);

(h) Select distinct cno from transaction;

View full question & answer
Question 95 Marks
Given the following relation: STUDENT

Table: STUDENT

No. Name Age Department Dateofadm Fee Sex
1 Pankaj 24 Computer 10/01/97 120 M
2 Shalini 21 History 24/03/98 200 F
3 Sanjay 22 Hindi 12/12/96 300 M
4 Sudha 25 History 01/07/99 400 F
5 Rakesh 22 Hindi 05/09/97 250 M
6 Shakeel 30 History 27/06/98 300 M
7 Surya 34 Computer 25/02/97 210 M
8 Shikha 23 Hindi 31/07/97 200 F

Write SQL commands for the following queries

(a) To show all information about the students of History department.

(b) To list the names of female students who are in Hindi department.

(c) To list the names of all students with their date of admission in ascending order.

(d) To display student’s name, fee, age for male students only.

(e) To count the number of students with Age>23.

View full question & answer
Question 105 Marks
Consider the following table Student & Stream.

Table: Student

Admno Sname Class Sec Fee Mobile Area S_ID
1001 RAMESH XII A 2500 987654321 Madipur 10
1078 KRISHNA XII B 2400 999911111 Jawala Heri 30
1006 FARDEEN XII C 2600 987654321 Paschim Puri 40
1004 SUBHAM XII A 2500 963025874 Madipur 20
1029 KRITIKA XI C 2700 987456210 Madipur 30
1008 SAMEEKSHA XII A 2450 987123456 Mangol Puri 20
1025 SALMA XII B 2580 998877445 Madipur 30
1036 AMANDEEP XII B 2600 999333555 Khyala 40
1037 TEJAS XI C 2650 987951357 Paschim Puri 40
1029 HIMANSHU XII A 2750 951369874 Jawala Heri 10

Table : Stream

S_ID Stream_name
10 MEDILCAL
20 NON MEDICAL
30 COMMERCE WITH MATH
40 COMMERCE WITH IP
50 HUMANITIES

Write SQL commands for the statements (a) to (h) on the table: Student and Stream

(a) Display class and total fee collected from each class.

(b) Display admission no, students name and stream name.

(c) Display all the student details who have taken Commerce Stream.

(d) Count number of students who have opted for HUMANITIES stream.

(e) Display information of commerce with ip students whose name start with ‘S’. Arrange the record by admission number.

(f) Display details of all students who are in the MEDICAL stream.

(g) Display total fee of ‘Non-Medical’ Student.

(h) Change the name of the Column Sname to Student_Name.

View full question & answer
Question 115 Marks
Consider the following table Student & Stream.

Table: Student

Admno Sname Class Sec Fee Mobile Area S_ID
1001 RAMESH XII A 2500 987654321 Madipur 10
1078 KRISHNA XII B 2400 999911111 Jawala Heri 30
1006 FARDEEN XII C 2600 987654321 Paschim Puri 40
1004 SUBHAM XII A 2500 963025874 Madipur 20
1029 KRITIKA XI C 2700 987456210 Madipur 30
1008 SAMEEKSHA XII A 2450 987123456 Mangol Puri 20
1025 SALMA XII B 2580 998877445 Madipur 30
1036 AMANDEEP XII B 2600 999333555 Khyala 40
1037 TEJAS XI C 2650 987951357 Paschim Puri 40
1029 HIMANSHU XII A 2750 951369874 Jawala Heri 10

Table : Stream

S_ID Stream_name
10 MEDILCAL
20 NON MEDICAL
30 COMMERCE WITH MATH
40 COMMERCE WITH IP
50 HUMANITIES

Write SQL commands for the statements (a) to (h) on the above table: Student and Stream

(a) Identify Primary Keys and Foreign Key in the table student and primary key in Stream table given above.

(b) Display stream id and stream-wise total fee collected.

(c) Count no of students from each area.

(d) Display all the student details those who belongs to Madipur Area.

(e) Increase the fees of all students by10%.

(f) Display unique area from the student table.

(g) Display details of those students whose area contains ‘Puri’.

(h) Display the information of those students who are in class XII and section is either B or C.

View full question & answer
Question 125 Marks

Consider the following tables GAMES and PLAYER. Write SQL commands for the statements (a) to (d) and give outputs for SQL queries (e1) to (e4)

Relation: GAMES

GCode Game Name Number Prize Money Schedule Date
101 Carom Board 2 5000 3-Jan-2004
102 Badminton 2 12000 12-Dec-2003
103 Table Tennis 4 8000 14-Feb-2004
105 Chess 2 9000 01-Jan-2004
108 Lawn
Tennis
4 25000 19-Mar-2004

Relation: PLAYER

PCode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103

(a) To display the name of all Games with their Gcodes

(b) To display details of those games which are having PrizeMoney more than 7000.

(c) To display the content of the GAMES table in ascending order of ScheduleDate.

(d) To display sum of PrizeMoney for each of the Number of participation groupings (as shown in column Number)

(e1) Select COUNT(DISTINCT Number) FROM GAMES;

(e2) Select MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;

(e3) Select SUM(PrizeMoney) FROM GAMES;

(e4) Select DISTINCT Gcode FROM PLAYER;

View full question & answer
Question 135 Marks
Write SQL commands for (a) to (f) and write the outputs for (g) on the basis of tables FURNITURE and ARRIVALS

Table: FURNITURE

NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 White lotus Double Bed 23/02/2002 30000 25
2 Pink feather Baby cot 20/01/2002 7000 20
3 Dolphin Baby cot 19/02/2002 9500 20
4 Decent Office Table 01/01/2002 25000 30
5 Comfort zone Double Bed 12/01/2002 25000 25
6 Donald Baby cot 24/02/2002 6500 15
7 Royal Finish Office Table 20/02/2002 18000 30
8 Royal tiger Sofa 22/02/2002 31000 30
9 Econo sitting Sofa 13/12/2001 9500 25
10 Eating Paradise Dining Table 19/02/2002 11500 25

Table: ARRIVALS

NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 Wood Comfort Double Bed 23/03/2003 25000 25
2 Old Fox Sofa 20/02/2003 17000 20
3 Micky Baby cot 21/02/2003 7500 15

(a) To show all information about the Baby cots from the FURNITURE table.

(b) To list the ITEMNAME which are priced at more than 15000 from the FURNITURE table.

(c) To list ITEMNAME and TYPE of those items, in which date of stock is before 22/01/2002 from the FURNITURE table in descending order of ITEMNAME.

(d) To display ITEMNAME and DATEOFSTOCK of those items, in which the discount t percentage is more than 25 from FURNITURE table.

(e) To count the number of items, whose TYPE is “Sofa” from FURNITURE table.

(f) To insert a new row in the ARRIVALS table with the following data:

14,“Valvet touch”, “Double bed”, {25/03/03}, 25000,30

(g) Give the output of following SQL statement

Note: Outputs of the above mentioned queries should be based on original data given in both the tables i.e., without considering the insertion done in

(f) part of this question.

(i) Select COUNT(distinct TYPE) from FURNITURE;

(ii) Select MAX(DISCOUNT) from FURNITURE, ARRIVALS;

(iii) Select AVG(DISCOUNT) from FURNITURE where TYPE=”Baby cot”;

(iv) Select SUM(Price) from FURNITURE where DATEOFSTOCK<12/02/02;

View full question & answer
Question 145 Marks

Write SQL commands for the following queries on the basis of Club relation given below:

Relation: Club

Coach-ID CoachName Age Sports date_of_app Pay Sex
1 Kukreja 35 Karate 27/03/1996 1000 M
2 Ravina 34 Karate 20/01/1998 1200 F
3 Karan 34 Squash 19/02/1998 2000 M
4 Tarun 33 Basketball 01/01/1998 1500 M
5 Zubin 36 Swimming 12/01/1998 750 M
6 Ketaki 36 Swimming 24/02/1998 800 F
7 Ankita 39 Squash 20/02/1998 2200 F
8 Zareen 37 Karate 22/02/1998 1100 F
9 Kush 41 Swimming 13/01/1998 900 M
10 Shailya 37 Basketball 19/02/1998 1700 F

(a) To show all information about the swimming coaches in the club.

(b) To list the names of all coaches with their date of appointment (date_of_app) in descending order.

(c) To display a report showing coach name, pay, age, and bonus (15% of pay) for all coaches.

(d) To insert a new row in the Club table with ANY relevant data:

(e) Give the output of the following SQL statements:

(i) Select COUNT(Distinct Sports) from Club;

(ii) Select Min(Age) from Club where SEX = “F”;

View full question & answer
Question 155 Marks
Write SQL commands for the following queries based on the relation Teacher given below:

Table: Teacher

No Name Age Department Date_of_join Salary Sex
1 Jugal 34 Computer 10/01/97 12000 M
2 Sharmila 31 History 24/03/98 20000 F
3 Sandeep 32 Maths 12/12/96 30000 M
4 Sangeeta 35 History 01/07/99 40000 F
5 Rakesh 42 Maths 05/09/97 25000 M
6 Shyam 50 History 27/06/98 30000 M
7 Shiv Om 44 Computer 25/02/97 21000 M
8 Shalakha 33 Maths 31/07/97 20000 F

(a) To show all information about the teacher of Computer department.

(b) To list the names of female teachers who are in Maths department.

(c) To list the names of all teachers with their date of joining in ascending order.

(d) To display teacher’s name, salary, age for male teachers only.

(e) To count the number of teachers with Age>23.

View full question & answer
Question 165 Marks
Consider the following tables Product and Client. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (vii)

TABLE: PRODUCT

P_ID Product Name Manufacturer Price
TP01 Talcom Powder LAK 40
FW05 FaceWash ABC 45
BS01 Bath Soap ABC 55
SH06 Shampoo XYZ 120
FW12 Face Wash XYZ 95

TABLE: CLIENT

C_ID ClientName City P_ID
01 Cosmetic Shop Delhi FW05
06 Total Health Mumbai BS01
12 Live Life Delhi SH06
15 Pretty Woman Delhi FW12
16 Dreams Bangalore TP01

(i) To display the details of those Clients whose City is Delhi

(ii) To display the details of Products whose Price is in the range of 50 to 100 (Both values included)

(iii) To display the ClientName, City from Table Client, and ProductName and Price from table Product, with their corresponding matching P_ID

(iv) To increase the Price of all Products by 10

(v) SELECT DISTINCT CITY FROM Client;

(vi) SELECT Manufacturer, MAX(Price), Min(Price), Count(*) FROM Product GROUP BY Manufacturer;

(vii) SELECT ClientName, ManufacturerName FROM Product, Client WHERE Client.Prod_Id = Product.P_Id;

Answer
(i) Select * from client where city=”Delhi”;

(ii) Select * from product where price between 50 and 100;

(iii) Select a.clientname,a.city ,b.productname, b.price from client a, product b where a.P_ID and b.P_ID;

(iv) Update product set price = price +10;

(v) City

Banglore

Delhi

Mumbai

(vii)

Client Name Manufacturer
Total Health ABC
Cosmetic Shop ABC
Pretty Woman XYZ
Live Life XYZ
Dreams LAK
View full question & answer
5 Marks Each - Computer Science STD 12 Humanities Questions - Vidyadip