In MySQL we can write this query. Assuming there's a column field1 & field2 and a table table1.
select IF(field1 > 10, true, field2) AS `mycolumn` from table1
How can I achieve similar logic with Teradata query?
CodePudding user response:
Use a CASE
expression:
SELECT CASE WHEN field1 > 10 THEN 'true' ELSE field2 END AS mycolumn
FROM table1;
The above assumes that field2
be a text column. If not, then the 'true'
in the CASE
expression would have to be replaced with a literal matching the type of field2
.