Given below is my select query
select
case
when mobile||', '||phoneoff <>', ' then mobile||', '||phoneoff
when phoneoff='' and mobile<>'' then mobile
when phoneoff<>'' and mobile='' then phoneoff
else 'NIL'
end as "Concat_result",phoneoff,mobile
from gtab12
Result
Concat_result| phoneoff | mobile
-------------------+------------+----------
9544070335, 2812111|2812111 |9544070335
NIL| |
, 0479-2436762|0479-2436762|
9495758057, | |9495758057
what I'm trying to achieve is,
if both phoneoff and mobile have value then it should concatenate with a , see Concat_result col in the first row in the result
If phoneoff and mobile are = '' then Concat_result should print NIL
If phoneoff<>'' and mobile='' then Concat_result should print phoneoff only (see row 3 in my result its showing phoneoff along with ,) and same for mobile<>''
Expecting Result
Concat_result| phoneoff | mobile
-------------------+------------+----------
9544070335, 2812111|2812111 |9544070335
NIL| |
0479-2436762 |0479-2436762|
9495758057 | |9495758057