I have a large equation in a select statement that I need to reference in a where statement I think it is eating up my efficiency, I do not want to reference it more than I need to.
SELECT 'HeaderDetail' AS rowType, ... , [large CASE/WHEN statement] AS Tracking
...
WHERE NOT(@DNC IN([large CASE/WHEN statement]))
AND [large CASE/WHEN statement] IS NOT NULL
I feel like each time I call the statement it would need to recalculate the values and the query already takes a few seconds to run. Is there a way to reference the statement without having it to run the sub query multiple times?
Thanks in advance for the help!