756 views

1 Answer

0 votes
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 

 

Related questions

0 votes
0 votes
0 answers
1
mukul maurya asked Sep 1, 2018
868 views
0 votes
0 votes
0 answers
2
mukul maurya asked Sep 1, 2018
861 views
0 votes
0 votes
1 answer
3
mukul maurya asked Sep 1, 2018
559 views
0 votes
0 votes
1 answer
4
mukul maurya asked Sep 1, 2018
2,202 views
Identify the valid data type which can be used in sql to define type of data ?a. varcharb. memoc. numericd. string