Consider the table STUDENT given below and write the output of the SQL queries that follow.
SID |
SNAME |
MARKS |
GRADE |
SECTION |
101 |
RAVI |
85 |
A |
1 |
102 |
PRIYA |
90 |
A |
2 |
103 |
RAJU |
75 |
B |
1 |
104 |
ANITA |
80 |
B |
2 |
105 |
RANI |
70 |
C |
1 |
106 |
RAHUL |
65 |
C |
2 |
107 |
RAMESH |
95 |
A |
1 |
108 |
PREETI |
60 |
D |
2 |
(i) SELECT AVG(MARKS) FROM STUDENT WHERE GRADE = "A";
Answer:
Answer by student
The output of the SQL query is:
|
AVG(MARKS) |
|
90 |
Detailed answer by teachoo
-lock-
The given query calculates the average of the MARKS column from the table STUDENT, but only for those rows where the GRADE column is equal to “A”. This means that it will only consider the marks of RAVI, PRIYA and RAMESH, who have grade A. The average of their marks is (85+90+95)/3 = 90. Therefore, the output of this query is:
|
AVG(MARKS) |
|
90 |
-endlock-