I have a table vbap : For all distinct POSNR, PARVW, I need to check if POSNR=POSNR2, if it’s the case I select KUNNR. if POSNR<>POSNR2 and POSNR2 =’00000′ I select KUNNR
Result:
I didn’t understand how to do it?
Advertisement
Answer
This seems like just a where
cause:
select t.* from t where POSNR2 in (POSNR, '00000')
Perhaps you are trying to prioritize the rows, to select one row per kunnr
. If so:
select t.* from (select t.*, row_number() over (partition by parvw order by psnr2 desc) as seqnum from t where POSNR2 in (POSNR, '00000') ) t where seqnum = 1;