Home > database >  SQL Case statement for impala
SQL Case statement for impala

Time:10-28

I have below requirement in Impala, can someone please help me on this.

if table1.column1 is null or empty string ,then table1.column2 else concat(table1.column1," ",table1.column2) as address


select 
**the above condition** 
from table1.

CodePudding user response:

Try this

    Select case when  column1 is null or column1='' 
     then 
     column2 else concat(column1," ",column2) end as 
      address from table1

CodePudding user response:

Just use a Simple ISNULL. You don't need a case here

SELECT
    Address = LTRIM(RTRIM(ISNULL(Column1 ' ','') ISNULL(Column1,'')))
    FROM YourTable
  •  Tags:  
  • sql
  • Related