The Gateway to Computer Science Excellence
0 votes

The answer should be D, but C is provided as the answer.

in Databases by Active (4.6k points)
edited by | 94 views
Yes D is correct. Don't practise from Gateforum tests. Standard is not good , also lots of wrong keys, poorly explained solutions
Hmm, Thanks

I also feel the same.
What is problem with C?
In C, group by is not given, but we can use it with aggregate functions.
Without using group by, how will you use having? As you must be knowing that having is used to put conditions on groups
It is not mandatory that aggregate functions will be used in select clause only when group by is present in select statement.
But Sir, we also cannot use having without using group by.
C is correct ans.
how you would use aggregate function "IN" group by clause.
May be I am taking options in other sense.

I am considering given pairs seperately, but I think the question is asking that both pairs should be present in statement simultaneously. Is that so??
I think the question is only substandard with misleading question statement.

we also cannot use having without using group by.

this is false.... we can have a having clause without groupby clause.

select count(*)

from student

having count(*) > 2;


this query provide the output as no.of rows if no.of rows in student table is grater than 2 otherwise result nothing printed.

SQL contains having clause without groupby clause is meaningless but VALID.

But note that, if aggregate operator uses attributes, then groupby clause must present.


we have to consider each clause separetely,

where clause doesn't support aggregate operators ===> option a and b are ruledout

option c and option d both are correct.

the answer d is correct according to gate standard .

but c is correct to new standards of sql.

i think in gate they go with sql 93 as they go with basic sql so no doubt d is correct but if they go with higher versions like nowdays then c is also correct
@Shaik Masthan

can you please provide an example where we are using aggregate function in group by clause. for rest all, i know.

 aggregate function in group by clause. 

aggregate functions can't used by groupby clause.


in option D, " select groupby " means

you have grouped by some attribute ===> select statement should have the attributes used by groupby clause

and along with that it may have aggregate functions.

ok. got it. thanks

Please log in or register to answer this question.

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,666 questions
56,167 answers
93,994 users