SELECT S.Id, S.Name, S.Version, S.SoftNo
FROM SOFTWARE S WITH(NOLOCK)
WHERE (IF S.Version = 0 THEN S.Version > 0 ELSE S.Version = @Version)
AND (IF S.SoftNo = 0 THEN
SELECT col1, col2,
CASE
WHEN expression THEN return
WHEN expression THEN return
ELSE return
END AS NameOfNewColWithReturnValues
FROM Col_FROM_WHICH_TABLE