Find the output of the MySQL query based on the given table COACH (ignore the…
2023
Find the output of the MySQL query based on the given table COACH (ignore the output header).
Table: COACH
CID | CNAME | GAME | SALARY
G03 | VSHALI | NULL | 60000
G05 | YUVRAJA | CRICKET | NULL
G08 | MALKHAN | ATHLATICS| 80000
G09 | SACINDRA | CRICKET | NULL
Query:
SELECT COUNT(GAME), AVG(SALARY)
FROM COACH;
- A.
3, 70000
- B.
3, 5000
- C.
7, 50000
- D.
3,4000
Attempted by 1251 students.
Show answer & explanation
Correct answer: A
Given table COACH:
GAME values: NULL, CRICKET, ATHLATICS, CRICKET.
SALARY values: 60000, NULL, 80000, NULL.
Query: SELECT COUNT(GAME), AVG(SALARY) FROM COACH;
COUNT(GAME) counts only non-NULL values in the GAME column. The non-NULL GAME values are CRICKET, ATHLATICS, and CRICKET, so COUNT(GAME) = 3.
AVG(SALARY) ignores NULL values. The non-NULL SALARY values are 60000 and 80000, so AVG(SALARY) = (60000 + 80000) / 2 = 70000.
Final output: 3, 70000.
A video solution is available for this question — log in and enroll to watch it.