17.05 - Example: SELECT Statement With a Scalar Subquery in Its GROUP BY Clause - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)

The following example specifies a scalar subquery in its GROUP BY clause:

     SELECT sale_date, SUM(amount)
     FROM sales_table AS s
     GROUP BY sale_date, (SELECT prod_name 
                          FROM prod_table AS p
                          WHERE p.prod_no = s.prod_no);