I'm using Teradata. Trying to understand a very strange thing.
SELECT
ID,
TYPE,
'' AS SUB_TYPE
FROM Table_A
UNION ALL
SELECT
ID,
TYPE,
SUB_TYPE
FROM TABLE_B
Somehow, valid values of Table B become blank in the result.
ID | TYPE | SUB_YPE | comment |
---|---|---|---|
1 | A type from table A | correct, empty string as a constant | |
2 | A type from table B | incorrect, sub type has a value in B | |
3 | Another type from table B | null | correct, sub type is null in B |
But when I exchange query 1 and 2, everything works fine.
SELECT
ID,
TYPE,
SUB_TYPE
FROM TABLE_B
UNION ALL
SELECT
ID,
TYPE,
'' AS SUB_TYPE
FROM Table_A
ID | TYPE | SUB_TYPE | comment |
---|---|---|---|
2 | A type from table B | A sub type from table B | correct |
3 | Another type from table B | null | correct |
1 | A type from table A | correct |
This is bizarre, can anyone help explain?