Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

COALESCE in select statement

sabarna17
Contributor
0 Likes
3,286

Hi,

SELECT EBELN, INFNR,

        MATKL,

COALESCE( s~INFNR, s~MATKL ) AS ABCD

FROM EKPO AS s

UP TO 20 ROWS

INTO TABLE @DATA(lt_result).

I am using the previous code to test.

But if  s~INFNR is null and s~MATKL consists value, then also blank is displaying in ABCD column.

Need clarification.

-Sabarna

Hi,

SELECT EBELN, INFNR,

        MATKL,

COALESCE( s~INFNR, s~MATKL ) AS ABCD

FROM EKPO AS s

UP TO 20 ROWS

INTO TABLE @DATA(lt_result).

I am using the previous code to test.

But if  s~INFNR is null and s~MATKL consists value, then also blank is displaying in ABCD column.

Need clarification.

-Sabarna

2 REPLIES 2
Read only

former_member210008
Active Participant
0 Likes
1,153

Maybe there is a difference between NULL and INITIAL values in field? Try to replace coalesce with case when s~infnr is initial then 111 else s~infnr.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,153

Are you sure that INFNR is null, and not INITIAL (This is a very old field in this table so finding a null value ?)

NB: AFAIK for Database/DBMS that support ISNULL a COALESCE with 2 values is equal to a ISNULL

Regards,

Raymond