sql >> Base de Datos >  >> RDS >> Oracle

La expresión de caso no funciona correctamente en la consulta sql

El tercer caso es esperar un VARCHAR y está proporcionando un INT por lo que devuelve un error. El cambio fue que reemplacé 0 con '0'. Prueba esto:

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