17.10 - Example Query - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1147-171K
Language
English (United States)

Consider the following table definition and data:

CREATE TABLE Product_Life (Product_ID INTEGER,
                           Product_class VARCHAR(30), HOURS FLOAT);

INSERT INTO Product_Life VALUES (100, 'Bulbs', 100);
INSERT INTO Product_Life VALUES (100, 'Bulbs', 200);
INSERT INTO Product_Life VALUES (100, 'Bulbs', 300);

The following query uses the Java method that represents intermediate aggregate results as an object:

SELECT Product_ID, SUM(Hours), STD_DEV_OBJ(Hours)
FROM Product_Life
WHERE Product_Class = 'Bulbs'
GROUP BY Product_ID;

The following query uses the Java method that represents intermediate aggregate results as a byte array:

SELECT Product_ID, SUM(Hours), STD_DEV_BYTE(Hours)
FROM Product_Life
WHERE Product_Class = 'Bulbs'
GROUP BY Product_ID;