I am new to SQL coding. I would like to set my declared global variable like so. However when I do, it says that the column ratecode does not exist. This column is what I use in my "AS" statment. Is there a way to do this?
Declare @ratecodeVar varchar(15)
SELECT COALESCE(NULLIF(over_rate2,''), NULLIF(over_rate,''), std_rate) AS ratecode FROM dbo.matter WHERE clt_code = 'AME021' and mat_code = 'C133244'
SET @ratecodeVar = ratecode