I'm sure this should work, just can't get the syntax right.
I want to join 2 tables and depending on a flag in 1 of the tables vary the data that gets selected in the result, so if the select flag is set to 1 then only select where the appointment flag is 1 when the select flag is set to 0 then select regardless of the appointment flag
Code below gives an idea of what I'm looking for.
Thanks.
I love deadlines. I like the whooshing sound they make as they fly by
Douglas Adams
(1952-2001)
I want to join 2 tables and depending on a flag in 1 of the tables vary the data that gets selected in the result, so if the select flag is set to 1 then only select where the appointment flag is 1 when the select flag is set to 0 then select regardless of the appointment flag
Code below gives an idea of what I'm looking for.
Thanks.
Code:
select *
from Table1
inner join
Table2
on
Table1.CALLID = Table2.JOBID
where Table2.APPOINTMENT IN (CASE WHEN Table1.Flag = 1 THEN 1 ELSE Table1.Flag ="Anything" END)
I love deadlines. I like the whooshing sound they make as they fly by
Douglas Adams
(1952-2001)