SQL Flow Field Guide

APPROX_COUNT_DISTINCT

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

approximate aggregate

What changes

Input
expression over each group
Output or change
approximate distinct count
Return type
bigint

Syntax at a glance

APPROX_COUNT_DISTINCT ( expression )

Work example

Estimate a large distinct count when a small documented error is acceptable.

Compare the estimate with COUNT(DISTINCT) on a manageable sample before choosing it for reporting.

Check your work The result is approximate and is not suitable for exact billing or reconciliation.

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