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

The following example groups all items into deciles by profitability.

   SELECT Item, Profit, QUANTILE(10, Profit) AS Decile
   FROM
      (SELECT Item, Sum(Sales) — (Count(Sales) * ItemCost) AS Profit
      FROM DailySales, Items
      WHERE DailySales.Item = Items.Item
      GROUP BY Item) AS Item;

The result might look like the following table.

Item Profit Decile
High Tops 97112 9
Low Tops 74699 7
Running 69712 6
Casual 28912 3
Xtrain 100129 9