select * from abc a join( if @param=1 begin SELECT distinct [Act_ID] FROM [Asses] where [tobacco]=1 end if @param=2 begin SELECT distinct [Act_ID] FROM [Asses] where bariatricsupport=1 end if @param=3 begin SELECT distinct [Act_ID] FROM [Asses] where bariatricsurgery=1 end if @param=4 begin SELECT distinct [Act_ID] FROM [Asses] where stress=1 end if @param=5 begin SELECT distinct [Act_ID] FROM [Asses] where weight=1 end )C on a.Act_ID=c.Act_IDPlease let me know if this is possible if not is there any approach better suits my scenario?
↧
Can i join a table based on If Condition
↧