PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

SQL · Theory

HAVING

← All stacks

Theory

45/439

HAVING

HAVING sits in the report. Rohit’s job is subjects with avg > 60. Write that first.

Do HAVING once by hand. HAVING AVG(marks) > 60. Change one input. Say the new result out loud.

Without HAVING, the report gets messy and subjects with avg > 60 is hard to trust.

Rohit ships HAVING in the report. That is the use case worth saying.

HAVING trap — WHERE instead of HAVING on aggregates. Rohit loses marks for that every viva.

HAVING is not a lonely heading. Rohit ties it to subjects with avg > 60.

Close HAVING with — “If I skip it, subjects with avg > 60 goes wrong like this: WHERE instead of HAVING on aggregates.”

Exam tip

Say HAVING in one breath, then HAVING AVG(marks) > 60, then WHERE instead of HAVING on aggregates.

HAVING — sample query

CREATE TABLE sales (id INTEGER PRIMARY KEY, region TEXT, amount INTEGER);
INSERT INTO sales VALUES (1, 'N', 100), (2, 'N', 80), (3, 'S', 120);
SELECT region, SUM(amount) AS total
FROM sales
GROUP BY region
HAVING total >= 150
ORDER BY total DESC;

HAVING — gROUP BY aggregates; HAVING filters groups; ORDER BY sorts the result.

Short notes

  • DefHAVING — Rohit uses it for subjects with avg > 60 in the report.
  • RuleHAVING → HAVING AVG(marks) > 60.
  • RememberHAVING + the query planner (the report).
  • UseHAVING in the report (subjects with avg > 60).
  • TrapHAVING — WHERE instead of HAVING on aggregates.
  • ExHAVING → subjects with avg > 60.

Questions

1

In one breath: what does HAVING do for Rohit?

2

When would Rohit actually reach for HAVING?

3

How do you catch WHERE instead of HAVING on aggregates?

4

Write the smallest HAVING step on subjects with avg > 60. What happens?

Previous← GROUP BYNextAND →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.