search
Log In
0 votes
187 views

in Databases 187 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 

 

Related questions

0 votes
0 answers
1
202 views asked Sep 2, 2018 in Databases mukul maurya 202 views
0 votes
0 answers
2
127 views asked Sep 2, 2018 in Databases mukul maurya 127 views
0 votes
1 answer
3
156 views asked Sep 2, 2018 in Databases mukul maurya 156 views
0 votes
1 answer
4
1k views
Identify the valid data type which can be used in sql to define type of data ? a. varchar b. memo c. numeric d. string
asked Sep 2, 2018 in Databases mukul maurya 1k views
...