PERCENTILE_CONT/PERCENTILE_DISC Function Example | Teradata Vantage - Example - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2024-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢

Using this table:

Area Address Price
Downtown 72 Easy Street 509000
Downtown 29 Right Way 402000
Downtown 45 Diamond Lane 203000
Downtown 76 Blind Alley 201000
Downtown 15 Tern Pike 199000
Downtown 444 Kanga Road 102000
Uptown 15 Peak Street 456000
Uptown 27 Primrose Path 349000
Uptown 44 Shady Lane 341000
Uptown 34 Design Road 244000
Uptown 2331 Highway 64 244000
Uptown 77 Sunset Strip 102000

The following SQL statement returns a computed result after doing linear interpolation, as shown in the following table.

SELECT area,
       AVG(price),
       PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY price),
       PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY price)
FROM market
GROUP BY area;
Area Average Price PERC_DISC PERC_CONT
Downtown 269333 201000 202000
Uptown 289333 244000 292500