Teradata - 根据是否以数字开头在两列之间进行选择

Teradata - selecting between two columns based on whether it starts with a number or not

我有一个类似于以下内容的查询:

SELECT
  s.cola, s.colb, t.colc, t.cold, u.cole, u.colf, u.colg, u.colh, u.coli, u.colj, u.colk, u.coll 
FROM table1 s
INNER JOIN table2 t
  ON s.colb = t.colc
INNER JOIN table3 u
  ON u.colm = t.cold
WHERE cast(s.cola as date) between date '2017-11-06' and date '2017-11-10'
ORDER BY 3

我需要添加一个名为 col_new 的新列,由 u.colmu.coln 填充。如果该列以数字开头,则该列将具有 u.colm 中的值。否则它将具有来自 u.coln 的值。众所周知,对于 table u.

中的每个条目,u.colnu.colm 都以数字开头

我尝试了以下查询来测试是否可以识别以数字开头的条目:

SELECT CASE WHEN ISNUMERIC(SUBSTRING(LTRIM(colm), 1, 1)) = 1
        THEN 'yes'
        ELSE 'no'
      END AS col_new
FROM table_u

返回错误:Syntax error: expected something between '(' and the 'substring' keyword.

请提出解决方案。

编辑: 确切错误:

[Teradata Database] [3706] Syntax error: expected something between '(' and the 'substring' keyword.

而不是isnumeric(),只是做一个比较:

SELECT (CASE WHEN LEFT(LTRIM(colm), 1) BETWEEN '0' AND '9' THEN 'yes'
             ELSE 'no'
        END) AS col_new
FROM table_u;

LEFT() 是一个方便的 shorthand 用于字符串的前 "n" 个字符。