Sponsor Area
TextBook Solutions for Uttarakhand Board Class 12 Computer And Communication Technology Computer Science With Python Chapter 10 Structure Query Language
Write the definition of a method OddSum(NUMBERS) to add those values in the list of NUMBERS, which are odd.
def OddSum(NUMBERS):
n=len(NUMBERS)
s=0
for i in range(n):
if (i%2!=0):
s=s+NUMBERS[i]
print(s) 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 |
MNAME |
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');
Observe the following STUDENTS and EVENTS tables carefully and write the name of the RDBMS operation which will be used to produce the output as shown in LIST? Also, find the Degree and Cardinality of the LIST.
STUDENTS
| No | Name |
| 1 | Tara Mani |
| 2 | Jaya Sarkar |
| 3 | Tarini Trikha |
EVENTS
| EVENTCODE | EVENTNAME |
| 1001 | Programming |
| 1002 | IT Quiz |
LIST
| No | Name | EVENTCODE | EVENTNAME |
| 1 | Tara Mani | 1001 | Programming |
| 1 | Tara Mani | 1002 | IT Quiz |
| 2 | Jaya Sarkar | 1001 | Programming |
| 2 | Jaya Sarkar | 1002 | IT Quiz |
| 3 | Tarini Trikha | 1001 | Programming |
| 3 | Tarini Trikha | 1002 | IT Quiz |
Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables
Table: VEHICLE
| CODE | VTYPE | PERKM |
| 101 | VOLVO BUS | 160 |
| 102 | AC DELUXE BUS | 150 |
| 103 | ORDINARY BUS | 90 |
| 105 | SUV | 40 |
| 104 | CAR | 20 |
Note:
- PERKM is Freight Charges per kilometre
- VTYPE is Vehicle Type
Table: TRAVEL
| NO | NAME | TDATE | KM | CODE | NOP |
| 101 | Janish | 2015-11-13 | 200 | 101 | 32 |
| 103 | Vedika Sahai | 2016-04-21 | 100 | 103 | 45 |
| 105 | Tarun Ram | 2016-03-23 | 350 | 102 | 42 |
| 102 | John Fen | 2016-02-13 | 90 | 102 | 40 |
| 107 | Ahmed Khan | 2015-01-10 | 75 | 104 | 2 |
| 104 | Raveena | 2016-05-28 | 80 | 105 | 4 |
| 106 | Kripal Anya | 2016-02-06 | 200 | 101 | 25 |
Note:
• NO is Traveller Number
• KM is Kilometer travelled
• NOP is number of travellers travelled in vehicle
• TDATE is Travel Date
- To display NO, NAME, TDATE from the table TRAVEL in descending order of NO.
- To display the NAME of all the travellers from the table TRAVEL who are travelling by vehicle with code 101 or 102.
- To display the NO and NAME of those travellers from the table TRAVEL who travelled between ‘2015â12â31’ and ‘2015â04â01’.
- To display all the details from table TRAVEL for the travellers, who have travelled distance more than 100 KM in ascending order of NOP.
- SELECT COUNT(*), CODE FROM TRAVEL
GROUP BY CODE HAVING COUNT(*)>1; - SELECT DISTINCT CODE FROM TRAVEL;
- SELECT A.CODE,NAME,VTYPE
FROM TRAVEL A,VEHICLE B
WHERE A.CODE=B.CODE AND KM<90; - SELECT NAME,KM*PERKM
FROM TRAVEL A,VEHICLE B
WHERE A.CODE=B.CODE AND A.CODE=’105’;
Sponsor Area
Sponsor Area
Mock Test Series
Mock Test Series



