I have the following SQL statement:
WITH w1 AS (SELECT [Number] AS v1 FROM [MyTable] WHERE <condition>)
SELECT
SUM(CASE WHEN v1 < @Value THEN v1 ELSE @Value END)
FROM
w1;
I’m just curious, say if MyTable contains 10 records matching to , how many times will the statement be processed while performing the SQL statement above?
That will just get inlined and treated the same as if you had written