• LEFT OUTER JOIN Information_Sales A ON Case IF EID = 0 or PID = 0 then SID = 148 ELSE UDF.NEW (EID,PID) = A.SID

    Its important to remember that a CASE expression is an expression, which produces a single scalar value. It is not an IF clause.

    Assuming that the SID = 148 and A.Sid are the same column. You want something more like this

    LEFT OUTER JOIN Information_Sales A on A.SID = Case When EID = 0 then 148 when PID = 0 then 148 else UDF.NEW (EID,PID) end

    ---------

    Note: NO guarantees on performance of such a join. You may well be better off doing separate queries

    LEFT OUTER JOIN Information_Sales A on SID = 148

    WHERE EID = 0 or PID = 0

    LEFT OUTER JOIN Information_Sales A on UDF.NEW (EID,PID)

    WHERE EID <> 0 and PID <> 0

    As has already been pointed out. A lot more information is needed before anyone can give you solid, specific advice.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills