Questions

4 Marks Each

🎯

Test yourself on this topic

4 questions · timed · auto-graded

Question 14 Marks

Answer the following questions:

Students

Adm No Name Class Sec R No. Address Phone
1271 Utkarsh Madam 12 C 1 C-32, Punjabi Bagh 4356154
1324 Naresh Sharma 10 A 1 31, Mohan Nagar 435654
1325 Md. Yusuf 10 A 2 12/12, Chand Nagar 145654
1328 Sumedha 10 B 23 59, Moti Nagar 4135654
1364 Subya Akhtar 11 B 13 12, Janak Puri Null
1434 Varuna 12 B 21 69, Rohini Null
1461 David DSouza 11 B 1 D-34, Model Town 243554. 98787665
2324 Satinder Singh 12 C 1 1/2, Gulmohar Park 143654
2328 Peter Jones 10 A 18 21/328, Vishal Enclave 24356154
2371 Mohini Mehta 11 C 12 37, Raja Garden 435654, 6765787

Sports

Adm No Game CoachName Grade
1324 Cricket Narendra A
1326 Volleball M.P. Singh A
1271 Volleball M.P. Singh B
1434 Basket Ball I. Malhotra B
1461 Cricket Narendra B
2328 Basket Ball I. Malhotra A
2371 Basket Ball I. Malhotra A
1271 Basket Ball I. Malhotra A
1434 Cricket Narendra A
2328 Cricket Narendra B
1364 Basket Ball I. Malhotra B

(a) Based on these tables write SQL statements for the following queries:

(i) Display the lowest and the highest classes from the table STUDENTS.


(ii) Display the number of students in each class from the table STUDENTS.

(iii) Display the number of students in class 10.

(iv) Display details of the students of Cricket team.

(v) Display the Admission number, name, class, section, and roll number of the students whose grade in Sports table is 'A'.

(vi) Display the name and phone number of the students of class 12 who are play some game.

(vii) Display the Number of students with each coach.

(viii) Display the names and phone numbers of the students whose grade is 'A' and whose coach is Narendra.

(b) Identify the Foreign Keys (if any) of these tables. Justify your choices.

(c) Predict the output of each of the following SQL statements, and then verify the output by actually entering these statements:

(i) SELECT class, sec, count(*) FROM students GROUP BY class, sec;

(ii) SELECT Game, COUNT(*) FROM Sports GROUP BY Game;]

(iii) SELECT Game FROM students, Sports WHERE students.admno = sports.admno AND Students.AdmNo = 1434;

Answer

(a) (i) SELECT MIN(CLASS),MAX(CLASS) from student;

(ii) SELECT Class, count(*) from Student group by students;

(iii) SELECT count(*) from students where class=10;

(iv) SELECT Students.* from Students A, Sports B Where A.Admno=B.Admno and Game="Cricket ";

(v) SELECT A.Admno,name,class,section,rno from Students A, Sports B Where A.Admno=B.Admno and grade=’A ’;

(vi) SELECT name, phone from from Students A, Sports B Where A.Admno=B.Admno and class=12;

(vii) Select coachname, count(*) from sports group by coachname;

(viii) SELECT NAME, phone from from Students A, Sports B where A.Admno=B.Admno and coachname=’Narendra ’and grade=’A ’;

(b) Foreign Key –Sports, because it is duplicating in the table.

(c) (i)]

Class Sec Count(*)

10

10

11

11

12

12

A

B

B

C

B

C

3

1

2

1

1

2

6 rows in set (0.08 sec)

(ii)

Class Count(*)

Basket Ball

Cricket

Volleball

4

4

2

3 rows in set (0.03 sec)

(iii)

Game Name Address

Cricket

Volleball

Basket Ball

Basket Ball

Cricket

Naresh Sharma

Subya Akhtar

Peter Jones

Mohini Mehta

Varuna

31, Mohan Nagar

12, Janak Puri

21/32B, Vishali Enclave

37, Raja Garden

69, Rohini

View full question & answer
Question 24 Marks

Write the output for the following commands:

Table- Loan_accounts

account cust_name loan_amount installment int_rate start_rate interest
1 R.K. Gupta 300000 36 12.00 2009-07-19 Null
2 S.P. Sharma 500000 48 10.00 2008-03-22 Null
3 K.P. Jain 300000 36 Null 2007-08-03 Null
4 M.P. Yadav 800000 60 10.00 2008-12-06 Null
5 S.P. Sinha 200000 36 12.50 2010-01-03 Null
6 P. Sharma 700000 60 12.50 2008-06-05 Null
7 K.S. Dhall 500000 48 Null 2008-03-05 Null

(a)

(b)

(c)

(d)

(e)

Answer

(a)

(b)

(c)

(d)

(e)

View full question & answer
Question 34 Marks

Create the following table named "Charity "and write SQL queries for the tasks that follow:

Table: Charity

P_Id LastName FirstName Address City Contribution
1 Bindra Jaspreet 5B, Gomti Nagar Lucknow 3500.50
2 Rana Monica 21 A, Bandra Mumbai 2768.00
3 Singh Jatinder 8, Punjabi Bagh Delhi 2000.50
4 Arora Satinder K/1, Shere Punjab Colony Mumbai 1900.00
5 Krishnan Vineeta A-75, Adarsh Nagar

(i) Display all first names in lowercase.

(ii) Display all last names of people of Mumbai city in uppercase.

(iii) Display Person Id along with First 3 characters of his/her name.

(iv) Display first name concatenated with last name for all the employees.

(v) Display length of address along with Person Id.

(vi) Display last 2 characters of City and Person ID.

(vii) Display Last Names and First names of people who have "at "in the second or third position in their first names.

(viii) Display the position of 'a' in Last name in every row.

(ix) Display Last Name and First name of people who have "a "as the last character in their First names.

(x) Display the first name and last name concatenated after removing the leading and trailing blanks.

(xi) Display Person Id, last names and contribution rounded to the nearest rupee of all the persons.

(xii) Display Person Id, last name and contribution with decimal digits truncated of all the persons.

(xiii) Display Last name, contribution and a third column which has contribution divided by 10. Round it to two decimal points.

View full question & answer
Question 44 Marks
Write the output for the following commands:

Table- Loan_accounts

account cust_name loan_amount installment int_rate start_rate interest
1 R.K. Gupta 300000 36 12.00 2009-07-19 Null
2 S.P. Sharma 500000 48 10.00 2008-03-22 Null
3 K.P. Jain 300000 36 Null 2007-08-03 Null
4 M.P. Yadav 800000 60 10.00 2008-12-06 Null
5 S.P. Sinha 200000 36 12.50 2010-01-03 Null
6 P. Sharma 700000 60 12.50 2008-06-05 Null
7 K.S. Dhall 500000 48 Null 2008-03-05 Null

(a)

(b)

(c)

(d)

(e)

Answer

(a)

(b)

(c)

(d)

(e)

View full question & answer
4 Marks Each - Computer Science STD 12 Humanities Questions - Vidyadip