I want to concat columns of supplier table with comma separator and put it into an alias field named \'contact\'. I have used cases for checking null values. Suppos
The third case is expecting a VARCHAR and you are providing an INT because of which it is returning an error. Change was that I replaced 0 with '0'. Try this:
SELECT supplier_Name,supplier_Address,supplier_reference,contact_Number1,contact_number2, contact_number3,
(case
when contact_number2 is null then contact_number3
when contact_number3 is null then contact_number2
when contact_number3 is null and contact_number2 is null then '0'
when contact_number2 is not null and contact_number3 is not null then CONCAT(CONCAT(contact_number2,','), contact_number3)
end)
as contact