GateAI
SQL

GATE CSE 2012 · Q15

MCQ1 markMedium

Time

Which of the following statements are TRUE about an SQL query? P : An SQL query can contain a HAVING clause even if it does not have a GROUP BY clause Q : An SQL query can contain a HAVING clause only if it has a GROUP BY clause R : All attributes used in the GROUP BY clause must appear in the SELECT clause S : Not all attributes used in the GROUP BY clause need to appear in the SELECT clause

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) Q and R

SQL

According to the official GATE key, the correct pair of statements is Q and R (Option C):

  • Statement Q: In standard database query formulation, the HAVING clause is specifically designed to apply conditions on the groups created by a GROUP BY clause.

  • Statement R: In conventional SQL query design tested in this context, attributes that define the groups in the GROUP BY clause are expected to appear in the projection list (SELECT clause) to represent the grouped results.

Thus, option C (Q and R) corresponds to the official answer key.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This SQL previous year question is Q15 of the GATE CSE 2012 paper. Find more GATE CSE PYQs on SQL in Databases, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related SQL PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

SQL in GATE CSE

SQL has 17 GATE CSE PYQs across 14 papers from 2011 to 2025. 6 of them are 1-mark MCQs like this one, and GATE CSE 2012 has 2.

How GATE tests SQL

More from GATE CSE 2012

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2012 · Q15 · MCQ

Which of the following statements are TRUE about an SQL query? P : An SQL query can contain a HAVING clause even if it does not have a GROUP BY clause Q : An SQL query can contain a HAVING clause only if it has a GROUP BY clause R : All attributes used in the GROUP BY clause must appear in the SELECT clause S : Not all attributes used in the GROUP BY clause need to appear in the SELECT clause

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.