CBSE Class 12 Informatics Practices
Question 60 of 79
Database Query using SQL — Question 18
Back to all questions 18
Question Consider the table RESULT given below. Write commands in MySQL for (a) to (d) and output for (e) to (g):
Table: RESULT
| No | Name | Stipend | Subject | Average | Division |
|---|---|---|---|---|---|
| 1 | Sharon | 400 | English | 38 | THIRD |
| 2 | Amal | 680 | Mathematics | 72 | FIRST |
| 3 | Vedant | 500 | Accounts | 67 | FIRST |
| 4 | Shakeer | 200 | Informatics | 55 | SECOND |
| 5 | Anandha | 400 | History | 85 | FIRST |
| 6 | Upasna | 550 | Geography | 45 | THIRD |
(a) To list the names of those students who have obtained Division as FIRST in the ascending order of NAME.
(b) To display a report listing Name, Subject and Annual Stipend received assuming that the Stipend column has monthly stipend.
(c) To count the number of students who have either Accounts or Informatics as subject.
(d) To insert a new row in the table RESULT: 7, "Mohan", 500, "English", 73, "Second"
(e) SELECT AVG(STIPEND) FROM RESULT WHERE DIVISION = "THIRD";
(f) SELECT COUNT(DISTINCT Subject) FROM RESULT;
(g) SELECT MIN(Average) FROM RESULT WHERE Subject = "English";
(a)
SELECT NAME
FROM RESULT
WHERE DIVISION = 'FIRST'
ORDER BY NAME;+---------+
| NAME |
+---------+
| AMAL |
| ANANDHA |
| VEDANT |
+---------+
(b)
SELECT NAME, SUBJECT, (STIPEND * 12) AS ANNUAL_STIPEND
FROM RESULT;+---------+-------------+----------------+
| NAME | SUBJECT | ANNUAL_STIPEND |
+---------+-------------+----------------+
| SHARON | ENGLISH | 4800 |
| AMAL | MATHEMATICS | 8160 |
| VEDANT | ACCOUNTS | 6000 |
| SHAKEER | INFORMATICS | 2400 |
| ANANDHA | HISTORY | 4800 |
| UPASNA | GEOGRAPHY | 6600 |
+---------+-------------+----------------+
(c)
SELECT COUNT(*)
FROM RESULT
WHERE SUBJECT IN ('ACCOUNTS', 'INFORMATICS');+----------+
| COUNT(*) |
+----------+
| 2 |
+----------+
(d)
INSERT INTO RESULT
VALUES(7, "MOHAN", 500, "ENGLISH", 73, "SECOND");(e)
+--------------+
| AVG(STIPEND) |
+--------------+
| 475.0000 |
+--------------+
(f)
+-------------------------+
| COUNT(DISTINCT Subject) |
+-------------------------+
| 6 |
+-------------------------+
(g)
+--------------+
| MIN(Average) |
+--------------+
| 38 |
+--------------+