CASE WHEN table1.text IS NULL THEN table2.numbers ELSE table1.text END AS newcolumn
When running this code I keep getting this error: ERROR: CASE types character varying and integer cannot be matched
You would think that this would not cause problems since I'm creating a new column within my query. I'd also like to point out that I'm using an old version of PostgreSQL if that helps.
CASE WHEN table1.text IS NULL THEN table2.numbers::text ELSE table1.text END AS newcolumn
Problem is you are trying to add table1.text and table2.numbers into a single column. These two columns are two diff data types. try following
CASE WHEN table1.text IS NULL THEN CAST(table2.numbers AS VARCHAR(50)) ELSE table1.text END AS newcolumn
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With