I've to Fetch Data in Condition Wise
Like If @SGType =1 then Single Customer else Customer in Group
Like
IF @SGType =1 then Select * from AgentMast Where AgentID = @AgentID;
IF @SGType =2 then Select * from AgentMast Where AgentID IN (SELECT SpCode from Trans WHERE AppCode = @AgentID)
I'm trying to write these both conditions in 1 syntax like
Select * from AgentMast Where
AgentID In (
CASE WHEN @SGType =1 then @AgentID
ELSE
SELECT SpCode from Trans WHERE AppCode = @AgentID
END
)
Can I do this.? I'm getting an error. But how to do this.?