Hi @Sullivan, Matthew ,
For this type of problem we recommend that you could post CREATE TABLE statements for your tables together with INSERT statements with sample data, enough to illustrate all angles of the problem. We also need to see the expected result of the sample.
According to your limited information, you could refer below example and check whether it is helpful.
create table #t
(
state_customer varchar(20),
appended_state varchar(20),
distance int
)
insert into #t values
('a','b',100),
(null,'c',100),
(null,null,100),
(null,null,200)
select case when ISNULL(state_customer, appended_state) IS NULL
then case when distance <= 100 then 'CA' end
else ISNULL(state_customer, appended_state)
end as US_State from #t
Output:
US_State
a
c
CA
NULL
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.