Which of the following command can display the SEC-wise average of the…
2023
Which of the following command can display the SEC-wise average of the students?
ROLLNO | NAME | SEC | MARKS |
80105 | MARIA | A | 83.0 |
80108 | AMAR | B | 44.0 |
80109 | MANPREET | A | 92.0 |
80112 | SAMEER | A | 81.0 |
80115 | AKBAR | B | NULL |
- A.
SELECT SEC, AVG(MARKS) FROM MYSTUDENT ORDER BY SEC;
- B.
SELECT SEC, AVG(MARKS) FROM MYSTUDENT GROUP BY MARKS;
- C.
SELECT SEC, AVG(MARKS) FROM MYSTUDENT GROUP BY SEC;
- D.
SELECT AVG(MARKS) FROM MYSTUDENT ORDER BY SEC;
Attempted by 1511 students.
Show answer & explanation
Correct answer: C
Key idea: group rows by SEC so AVG(MARKS) is computed for each section. Use this SQL command: SELECT SEC, AVG(MARKS) FROM MYSTUDENT GROUP BY SEC; GROUP BY SEC ensures one result row per section.
A video solution is available for this question — log in and enroll to watch it.