SQL Flow Field Guide

QUERY HINT { HASH | ORDER } GROUP

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

Specifies that aggregations that the query's GROUP BY or DISTINCT clause describes should use hashing or ordering.

What changes

Input
none
Output or change
none

Syntax at a glance

OPTION ( { HASH | ORDER } GROUP )

Work example

A measured query issue may justify testing QUERY HINT { HASH | ORDER } GROUP against the optimizer's default choice.

Capture the current plan, rows, reads, and elapsed time. Change one hint in a test copy and compare the same parameter values.

Check your work QUERY HINT { HASH | ORDER } GROUP. The intended plan behavior for QUERY HINT { HASH | ORDER } GROUP is visible and the result rows are unchanged across the comparison.

Open Microsoft Learn for full syntax, permissions, and details for your version.