The Gateway to Computer Science Excellence
0 votes
58 views

in Databases by (35 points) | 58 views

1 Answer

0 votes

Answer  - D.

Consider the above 2 queries :
SELECT AVG(marks) FROM Student

This query will query all the records in the student table and will give out average marks of all .

i.e. (sum of all marks) / (total number of rows).

Consider the other query-

SELECT section from Student where sex = 'M' group by section

This will return sections of the student's tables where student sex='M' 

Consider a table:

name sex section
a m 1
b m 2
c f 2
d m 3
e m 3

 

Query : select * from students where sex = 'm' group by section

Output :

name sex section
a m 1
b m 2
e m 3

 

Now, finally

SELECT section from Student where sex = 'M' group by section having AVG(marks) > SELECT AVG(marks) FROM Student

===

section of males having avg marks > avg marks of students 

 

by Active (2.3k points)

Related questions

0 votes
0 answers
1
asked Sep 2, 2018 in Databases by mukul maurya (35 points) | 70 views
0 votes
0 answers
2
asked Sep 2, 2018 in Databases by mukul maurya (35 points) | 44 views
0 votes
1 answer
3
asked Sep 2, 2018 in Databases by mukul maurya (35 points) | 96 views
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,258 answers
198,086 comments
104,735 users