1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. SELECT COUNT(*) FROM orders HAVING COUNT(*) > 100; is…

Added 30 Nov -0001

SELECT COUNT(*) FROM orders HAVING COUNT(*) > 100; is valid in PostgreSQL. What does HAVING do when no GROUP BY is written?

  1. It forms implicit groups from every selected column of the query output
  2. It filters the single implicit group, returning either one row or no rows at all Correct answer
  3. It is a syntax error, because HAVING always requires an explicit GROUP BY clause
  4. It filters individual rows before aggregation, exactly as a WHERE clause would

Correct answer

B. It filters the single implicit group, returning either one row or no rows at all

16 views

MCQSEXAM

Explanation

HAVING filters groups, and an aggregate query with no GROUP BY has exactly one implicit group covering all rows, so the clause can return that single row or suppress it entirely. It never filters individual rows; WHERE does that before grouping. Writing HAVING without a GROUP BY is the compact way to ask whether a table is large enough to matter.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More SQL for Data Analysis MCQs

Practise all SQL for Data Analysis MCQs

Similar MCQs