The GATE Grind

GATE 2012 CS (CS1) – Question 25

Databases · Relational Model: Relational Algebra, Tuple Calculus, SQL · 1 mark · Multiple choice

Which SQL assertions are true? P: HAVING can occur without GROUP BY. Q: HAVING requires GROUP BY. R: Every GROUP BY attribute must appear in SELECT. S: GROUP BY attributes need not all appear in SELECT.

  1. P and R
  2. P and S
  3. Q and R
  4. Q and S

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) Q and R

Explanation

The official key is C (Q and R), retained for historical grading. Under standard SQL, HAVING can apply to a single implicit group without an explicit GROUP BY, so P is true and Q false. Grouping columns need not all be projected, so S is true and R false. Thus B is the general SQL answer; the official C conflicts with those semantics.

More Relational Model: Relational Algebra, Tuple Calculus, SQL questions

All Relational Model: Relational Algebra, Tuple Calculus, SQL questions →