SQL Server - Aggregation & Filtering
3 min read

Can HAVING Work Without GROUP BY in SQL Server? (Yes, Here's Why)

Most SQL analysts learn to use HAVING with GROUP BY. But SQL Server doesn't always need both. Discover how implicit aggregation works, when to skip GROUP BY, and why it matters for real-world queries.

D

Dan Griffin

Senior Data Analyst · July 10, 2026

Can HAVING Work Without GROUP BY in SQL Server? (Yes, Here's Why)
In this article: HAVING does not require GROUP BY in SQL Server. Without GROUP BY, the qualifying rows form one implicit aggregate group, making the pattern useful when you want to return a single summary row only when an aggregate condition is met.

Can HAVING work without GROUP BY in SQL Server?

Yes.


And there is a practical reason a data analyst might actually want to do it.

Imagine the finance team asks:

"Alert me only if today's approved refunds exceed $50,000."

You don't need totals by customer, country, product, or payment method.

You need one answer about the entire filtered dataset.

A common instinct is to write:


SELECT
    SUM(RefundAmount) AS TotalApprovedRefunds
FROM dbo.PaymentRefunds
WHERE RefundStatus = 'Approved'
GROUP BY RefundStatus
HAVING SUM(RefundAmount) > 50000;


This works.

But ask yourself:

Why are we grouping by RefundStatus when WHERE already guarantees that every remaining row has RefundStatus = 'Approved'?

We can remove GROUP BY completely:


DECLARE @ReportDate date = '2026-10-05';

SELECT
    SUM(RefundAmount) AS TotalApprovedRefunds,
    COUNT_BIG(*) AS RefundCount
FROM dbo.PaymentRefunds
WHERE RefundStatus = 'Approved'
  AND RefundedAt >= @ReportDate
  AND RefundedAt < DATEADD(day, 1, @ReportDate)
HAVING SUM(RefundAmount) > 50000.00;


What's happening?

Without GROUP BY, SQL Server treats all rows that survive the WHERE clause as one implicit aggregated group.


Think about the query in two stages:

Keep Reading

Get free access to the full article

Join data professionals reading weekly SQL tips, career guides, and interview prep — completely free.

No credit card. No spam. Unsubscribe anytime.

Recommended Reading