SQL & Queries

Answer & solution
Official answer: C
Our answer: B
P is true: SELECT COUNT(*) FROM T HAVING COUNT(*)>0 is a valid aggregate query without GROUP BY, treating the input as one group. S is true: SELECT COUNT(*) FROM T GROUP BY a groups by a without selecting a. Therefore Q and R are false, and the correct pair is P and S, option B. The appended official Code A key instead prints C (Q and R). Preserve official C for scoring provenance and derived B as a documented source/key discrepancy; do not silently change either.
Check: On a table with values a=1,1,2, grouping by a while selecting only COUNT(*) returns counts 2 and 1 without exposing a. On the same nonempty table, HAVING COUNT(*)>0 without GROUP BY retains its one aggregate group. These concrete cases refute both universal claims Q and R.