Sorry about the name of the title but hard to describe my problem.
I am trying to capture NULLs on both ends. Meaning if sopnumbe is null then use order_num and if order_num is null then use sopnumbe AS master_SOP_Num.
This works ok if order_num is null it populates master_SOP_Num, but if sopnumbe is null it does not even pick up that record.
I tried method #1 and also #2 and they both give me the same results
#1
#2
Present results:
[tt]
master_sop_num sopnumbe order_num
342234 342234 342234
342235 342235 <null>
342237 342237 <null>
[/tt]
Desired results:
[tt]
master_sop_num sopnumbe order_num
342234 342234 342234
342235 342235 <null>
342236 <null> 342236
342237 342237 <null>
[/tt]
As you can see 342236 is missed altogether in my present code.
Thanks for your help
I am trying to capture NULLs on both ends. Meaning if sopnumbe is null then use order_num and if order_num is null then use sopnumbe AS master_SOP_Num.
This works ok if order_num is null it populates master_SOP_Num, but if sopnumbe is null it does not even pick up that record.
I tried method #1 and also #2 and they both give me the same results
#1
Code:
select case
when sopnumbe is null
then order_num
else sopnumbe
Code:
select Coalesce(order_num,sopnumbe ) As master_SOP_Num,
Present results:
[tt]
master_sop_num sopnumbe order_num
342234 342234 342234
342235 342235 <null>
342237 342237 <null>
[/tt]
Desired results:
[tt]
master_sop_num sopnumbe order_num
342234 342234 342234
342235 342235 <null>
342236 <null> 342236
342237 342237 <null>
[/tt]
As you can see 342236 is missed altogether in my present code.
Thanks for your help