17.05 - Example: Scalar Subquery in the WHERE Clause of a SELECT Statement - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Published
January 2021
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
vnq1596660420420.ditamap
dita:ditavalPath
hoy1596145193032.ditaval

You can specify a scalar subquery as an operand of a scalar predicate in the WHERE, HAVING, and QUALIFY clauses of a query.

The following example specifies a scalar subquery (SELECT AVG(price)…) as an operand in its WHERE clause.

     SELECT category, title, price
     FROM movie_titles AS t2
     WHERE (SELECT AVG(price) 
            FROM movie_titles AS t1
            WHERE t1.category = t2.category)<(SELECT AVG(price)
                                              FROM movie_titles);