Topic Wise Solved Problems Question – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
SUB-SQL:Exam Questions: siteicon
C05A-2017 2

Observe the following table CANDIDATE carefully and write the name of the RDBMS operation out of (i) SELECTION (ii) PROJECTION (iii) UNION (iv) CARTESIAN PRODUCT, which has been used to produce the output as shown in RESULT ? Also, find the Degree and Cardinality of the RESULT.

TABLE: CANDIDATE

NO NAME STREAM
C1 AJAY LAW
C2 ADITI MEDICAL
C3 ROHAN EDUCATION
C4 RISHAB ENGINEERING

RESULT

NO NAME
C3 ROHAN
CBSE12D-2017

C04B-2017 6

Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables
TABLE : BOOK

Code BNAME TYPE
F101 The priest Fiction
L102 German easy Literature
C101 Tarzan in the lost world Comic
F102 Untold Story Fiction
C102 War Heroes Comic

TABLE: MEMBER

MNO MNANE CODE ISSUEDATE
M101 RAGHAV SINHA L102 2016-10-13
M103 SARTHAK JOHN F102 2017-02-23
M102 ANISHA KHAN C101 2016-06-12

(i) To display all details from table MEMBER in descending order of ISSUEDATE.

(ii) To display the BNO and BNAME of all Fiction Type books from the table BOOK

(iii) To display the TYPE and number of books in each TYPE from the table BOOK

(iv) To display all MNAME and ISSUEDATE of those members from table MEMBER who have books issued (i.e ISSUEDATE) in the year 2017.

(v) SELECT MAX(ISSUEDATE) FROM MEMBER;

(vi) SELECT DISTINCT TYPE FROM BOOK;

(vii) SELECT A.CODE,BNAME,MNO,MNAME FROM BOOK A, MEMBER B
WHERE A.CODE=B.CODE ;

(viii) SELECT BNAME FROM BOOK
WHERE TYPE NOT IN (“FICTION”, “COMIC”);

CBSE12D-2017

C05A-2019S 8

Write SQL queries for (i) to (iv) and write outputs for SQL queries (v) to (viii), which are based on the table given below:

Table: TRAINS

TNO TNAME START END
11096 Ahimsa Express Pune Junction Ahmedabad Junction
12015 Ajmer Shatabdi New Delhi Ajmer Junction
1651 Pune Hbj Special Pune Junction Habibganj
13005 Amritsar Mail Howrah Junction Amritsar Junction
12002 Bhopal Shatabdi New Delhi Habibganj
12417 Prayag Raj Express Allahabad Junction New Delhi
14673 Shaheed Express Jaynagar Amritsar Junction
12314 Sealdah Rajdhani New Delhi Sealdah
12498 Shane Punjab Amritsar Junction New Delhi
12451 Shram Shakti Express Kanpur Central New Delhi
12030 Swarna Shatabdi Amritsar Junction New Delhi

Table:PASSENGERS

PNR TNO PNAME GENDER AGE TRAVELDATE
P001 13005 R N AGRAWAL MALE 45 2018-12-25
P002 12015 P TIWARY MALE 28 2018-11-10
P003 12015 S TIWARY FEMALE 22 2018-11-10
P004 12030 S K SAXENA MALE 42 2018-10-12
P005 12030 S SAXENA FEMALE 35 2018-10-12
P006 12030 P SAXENA FEMALE 12 2018-10-12
P007 13005 N S SINGH MALE 52 2018-05-09
P008 12030 J K SHARMA MALE 65 2018-05-09
P009 12030 R SHARMA FEMALE 58 2018-05-09

(i)  To display details of all Trains which Start from New Delhi.

(ii) To display the PNR, PNAME, GENDER and AGE of all Passengers whose AGE is below 50.

(iii) To display total number of MALE and FEMALE Passengers.

(iv) To display details 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;

CBSE12A-2019

C05B 6

Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables.
Table: ACCOUNT

ANO ANAME ADDRESS
101 Nirja Singh Bangalore
102 Rohan Gupta Chennai
103 Ali Reza Hyderabad
104 Rishabh Jain Chennai
105 Simran Kaur Chandigarh

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 101 12000 Deposit 2017-11-06

(i) To display details of all transactions of TYPE Deposit from Table TRANSACT.

(ii) To display the ANO and AMOUNT of all Deposits and Withdrawals done in the month of October 2017 from table TRANSACT.

(iii) To display the last date of transaction (DOT) from the table TRANSACT for the Accounts having ANO as 103.

(iv) To display all ANO, ANAME and DOT of those persons from tables ACCOUNT and TRANSACT who have done transactions 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-06-01’;

CBSE12A-2018

C05A 2

Observe the following tables VIDEO and MEMBER carefully and write the name of the RDBMS operation out of (i) SELECTION (ii) PROJECTION (iii) UNION (iv) CARTESIAN PRODUCT, which has been used to produce the output as shown below, Also, find the Degree and Cardinality of the final result.
TABLE: VIDEO

VNO VNAME TYPE
F101 The Last Battle Fiction
C101 Angels and Devils Comedy
C102 Daredevils Adventure

TABLE: MEMBER

MNO MNAME
M101 Namish Gupta
M102 Sana Sheikh
M103 Lara James

FINAL RESULT

VNO VNAME TYPE MNO MNAME
F101 The Last Battle Fiction M101 Namish Gupta
F101 The Last Battle Fiction M102 Sana Sheikh
F101 The Last Battle Fiction M103 Lara James
C101 Angels and Devils Comedy M101 Namish Gupta
C101 Angels and Devils Comedy M102 Sana Sheikh
C101 Angels and Devils Comedy M103 Lara James
A102 Daredevils Adventure M101 Namish Gupta
A102 Daredevils Adventure M102 Sana Sheikh
A102 Daredevils Adventure M103 Lara James
CBSE12A-2018

C05A 2

Observe the following table MEMBER carefully and write the name of the RDBMS operation out of (i) SELECTION (ii) PROJECTION (iii) UNION (iv) CARTESIAN PRODUCT, which has been used to produce the output as shown in RESULT. Also, find the Degree and Cardinality of the RESULT.

MEMBER

NO MNAME STREAM
M001 JAYA SCIENCE
M002 ADIYTA HUMANITIES
M003 HANSRAJ SCIENCE
M004 SHIVAK COMMERCE

RESULT

NO MNAME STREAM
M002 ADITYA HUMANITIES
CBSE12A-2017

C05B 6

Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables
DVD

DCODE DTITLE DTYPE
F101 Henry Martin Folk
C102 Dhrupad Classical
C101 The Planets Classical
F102 Universal Soldier Folk
R102 A day in life Rock

MEMBER

MID NAME DCODE ISSUEDATE
101 AGAM SINGH R102 2017-11-30
103 ARTH JOSEPH F102 2016-12-13
102 NISHA HANS C101 2017-07-24

(i) To display all details from the table MEMBER in descending order of ISSUEDATE.

(ii) To display the DCODE and DTITLE of all Folk Type DVDs from the table DVD

(iii) To display the DTYPE and number of DVDs in each DTYPE from the table DVD

(iv) To display all NAME and ISSUEDATE of those members from the table MEMBER who
have DVDs issued (i.e ISSUEDATE) in the year 2017

(v) SELECT MIN(ISSUEDATE) FROM MEMBER;

(vi) SELECT DISTINCT DTYPE FROM DVD;

(vii) SELECT D.DCODE,NAME,DTITLE
FROM DVD D, MEMBER M WHERE D.DCODE=M.DCODE ;

(viii) SELECT DTITLE FROM DVD
WHERE DTYPE NOT IN ( ” Folk ” , ” Classical ” );

CBSE12A-2017

C05A 2

Observe the following PARTICIPANTS and EVENTS tables carefully and write the name of the RDBMS operation which will be used to produce the output as shown in RESULT ? Also, find the Degree and Cardinality of the result.

PARTICIPANTS

PNO NAME
1 Aruanabha Tariban
2 John Fedricks
3 Kanti Desai
EVENTS

EVENTCODE EVENTNAME
1001 IT Quiz
1002 Group Debate

RESULT

PNO NAME EVENTCODE EVENTNAME
1 Aruanabha Tariban 1001 IT Quiz
1 Aruanabha Tariban 1002 Group Debate
2 John Fedricks 1001 IT Quiz
2 John Fedricks 1002 Group Debate
3 Kanti Desai 1001 IT Quiz
3 Kanti Desai 1002 Group Debate
CBSE12A-2016

C05B 6

Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables

Table: VEHICLE

VCODE VEHICLETYPE PERKM
V01 VOLVO BUS 150
V02 AC DELUXE BUS 125
V03 ORDINARY BUS 80
V05 SUV 30
V04 CAR 18

Note: PERKM is Freight Charges per kilometer

Table: TRAVEL

CNO CNAME TRAVELDATE KM VCODE NOP
101 K.Niwal 2015-12-13 200 V01 32
103 Fredrick Sym 2016-03-21 120 V03 45
105 Hitesh Jain 2016-04-23 450 V02 42
102 Ravi Anish 2016-01-13 80 V02 40
107 John Malina 2015-02-10 65 V04 2
104 Sahanubhuti 2016-01-28 90 V05 4
106 Ramesh Jaya 2016-04-06 100 V01 25

Note:

  • Km is Kilometers travelled
  • NOP is number of passengers travelled in vehicle

(i) To display CNO, CNAME, TRAVELDATE from the table TRAVEL in descending order of CNO.

(ii) To display the CNAME of all the customers from the table TRAVEL who are traveling by vehicle with code V01 or V02.

(iii) To display the CNO and CNAME of those customers from the table TRAVEL who travelled between ’2015-12-31’ and ‘2015-05-01’.

(iv) To display all the details from table TRAVEL for the customers, who have travel distance more than 120 KM in ascending order of NOP.

(v) SELECT COUNT(*),VCODE FROM TRAVEL GROUP BY VCODE HAVING COUNT(*)>1;

(vi) SELECT DISTINCT VCODE FROM TRAVEL;

(vii) SELECT A.VCODE,CNAME,VEHICLETYPE
FROM TRAVEL A,VEHICLE B
WHERE A.VCODE=B.VCODE AND KM<90;

(viii) SELECT CNAME,KM*PERKM
FROM TRAVEL A,VEHICLE B
WHERE A.VCODE=B.VCODE AND A.VCODE=’V05′;

CBSE12A-2016

C05A-2015 2

Observe the following table carefully and write the names of the most appropriate columns, which can be considered as (i) candidate keys and (ii) primary key.

Code Item Qty Price Transaction Date
1001 Plastic Folder 14” 100 3400 2014-12-14
1004 Pen Stand Standard 200 4500 2015‐01‐31
1005 Stapler Mini 250 1200 2015-02-28
1009 Punching Machine Small 200 1400 2015-03-12
1003 Stapler Big 100 1500 2015-02-02
CBSE12A-2015

C05B-2015 6

Consider the following DEPT and EMPLOYEE tables. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii).
Table: DEPT

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

Table: EMPLOYEE

ENO 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 employees.

(i) To display Eno, Name, Gender from the table EMPLOYEE in ascending order of Eno.

(ii) To display the Name of all the MALE employees from the table EMPLOYEE.

(iii) To display the Eno and Name of those employees from the table EMPLOYEE w ho are born between ‘1987-01-01’ and ‘1991-12-01’.

(iv) To count and display FEMALE employees who have joined after ‘1986-01-01’.

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

(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;

(vii) SELECT NAME, DEPARTMENT FROM EMPLOYEE E, DEPT D WHERE E.DCODE=D.DCODE AND EN0<1003;

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

CBSE12A-2015