hi,
Suppose I want to do the following:
DECLARE @num
SET @num = -1 /* initial value */
SELECT col1, col2,
CASE @num
WHEN -1 THEN ( [assign a value to @num], [return that value] )
ELSE @num
END AS 'num'
FROM T1
In English, I only want the @num variable to be calculated once but appear in every column of the SELECT result, since table T1 has many rows.
Greatly appreciate any help... thanks in advance!!