16.20 - Example - Teradata Vantage NewSQL Engine

Teradata Vantageā„¢ SQL Functions, Expressions, and Predicates

prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1145-162K

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 table immediately below.

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