CBSE Class 12 Informatics Practices
Question 71 of 91
JOINS and SET Operations — Question 7
Back to all questions 7
Question In a Database Karnataka_Sangam there are two tables with the instances given below :
Table : STUDENTS
| ADMNO | NAME | CLASS | SEC | RN | ADDRESS | PHONE |
|---|---|---|---|---|---|---|
| 1211 | Meena | 12 | D | 4 | A-26 | 3245678 |
| 1212 | Vani | 10 | D | 1 | B-25 | 5456789 |
| 1213 | Meena | 12 | A | 1 | ||
| 1214 | Karish | 10 | B | 3 | AB-234 | 4567890 |
| 1215 | Suraj | 11 | C | 2 | ZW12 | 4345677 |
Table : SPORTS
| ADMNO | GAME | COACHNAME | GRADE |
|---|---|---|---|
| 1215 | Cricket | Mr. Ravi | A |
| 1213 | Vollyball | Ms. Chadha | B |
| 1211 | Vollyball | Mr. Govardhan | A |
| 1212 | Basket Ball | Mr. Tewani | B |
Write SQL queries for the following :
(i) To count how many addresses are not having NULL values in the address column of STUDENTS table.
(ii) To display Name, Class from STUDENTS table and the corresponding Grade from SPORTS table.
(iii) To display Name of the student and their corresponding Coachnames from STUDENTS and SPORTS tables.
(i)
SELECT COUNT(ADDRESS) FROM STUDENTS;+----------------+
| COUNT(ADDRESS) |
+----------------+
| 4 |
+----------------+
(ii)
SELECT S.NAME, S.CLASS, SP.GRADE
FROM STUDENTS S, SPORTS SP
WHERE S.ADMNO = SP.ADMNO;+-------+-------+-------+
| NAME | CLASS | GRADE |
+-------+-------+-------+
| MEENA | 12 | A |
| VANI | 10 | B |
| MEENA | 12 | B |
| SURAJ | 11 | A |
+-------+-------+-------+
(iii)
SELECT S.NAME, SP.COACHNAME
FROM STUDENTS S, SPORTS SP
WHERE S.ADMNO = SP.ADMNO;+-------+--------------+
| NAME | COACHNAME |
+-------+--------------+
| MEENA | MR.GOVARDHAN |
| VANI | MR.TEWANI |
| MEENA | MS.CHADHA |
| SURAJ | MR.RAVI |
+-------+--------------+