CASE Expression Error Conditions - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530

The following conditions or expressions are considered illegal in a CASE expression:

Condition or Expression Example
A condition after the keyword CASE is supplied.
SELECT CASE a=1
        WHEN 1
        THEN 1
        ELSE 0
        END
FROM t;
A non valid WHEN expression is supplied in a valued CASE expression.
SELECT CASE a
        WHEN a=1
        THEN 1 
        ELSE 0 
       END 
FROM t;
A non valid WHEN condition is supplied in a searched CASE expression.
SELECT CASE 
        WHEN a
        THEN 1 
        ELSE 0 
       END 
FROM t;
SELECT CASE
        WHEN NULL
        THEN 'NULL'
       END
FROM table_1;
A non-scalar subquery is specified in a WHEN condition of a searched CASE expression.
SELECT CASE 
        WHEN t.a IN 
         (SELECT u.a 
          FROM u)
        THEN 1 
        ELSE 0 
       END 
FROM t;
A CASE expression references multiple UDTs that are not identical.
SELECT CASE t.shape.gettype()
        WHEN 1 
        THEN NEW circle('18,18,324')
        WHEN 2
        THEN NEW square('20,20,400')
       END;