SQL Flow Field Guide

PERCENTILE_DISC

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

inverse distribution (window)

What changes

Input
ordered values (WITHIN GROUP) within an OVER partition
Output or change
percentile value from the set per row
Return type
The return type is determined by the order_by_expression type.

Syntax at a glance

PERCENTILE_DISC ( numeric_literal ) WITHIN GROUP ( ORDER BY order_by_expression [ ASC | DESC ] ) OVER ( [ <partition_by_clause> ] )

Work example

Select an observed ordered value at a requested percentile position.

Test a tie, partition boundary, and one-row partition. State the order and frame in the query.

Check your work The output is an input value and can differ from PERCENTILE_CONT when interpolation would occur.

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