Reputation: 65
I have the following SQL
Select *
from PS_VENDOR
WHERE VENDOR IN ('111','222','333','444')
in which 444 VENDOR doesn't exist. but when I run the SQL I should get all 4 rows with all Vendors from IN CLAUSE and for 444 just populate BLANK or 'X'
I tried the following and it don't work
Select *
from PS_VENDOR
WHERE NVL(VENDOR IN ('111','222','333','444'), 'X');
Upvotes: 2
Views: 79
Reputation: 11205
Use a CTE to hold your values, left join
with V1 as
(
select '111' as VV from dual
union all
select '222' as VV from dual
union all
select '333' as VV from dual
union all
select '444' as VV from dual
)
select VV, PS_VENDOR.*
from V1
left join PS_VENDOR
on VENDOR = VV
Upvotes: 6