Is it possible to create, inside a single select statement, like this:
SELECT name, CASE WHEN name = 'a' THEN 'a' ELSE 'b' END tag, CASE WHEN tag = 'a' THEN 'a2' ELSE tag = 'b2' END tag2 FROM table_name
My reason is there is a previous column on the single statement where I want to use its case statement result on my other column.
I want to know if it can be done using variables like:
SELECT name, CASE WHEN name = 'a' THEN 'a' ELSE 'b' END @result = tag, CASE @result WHEN 'a' THEN 'a2' ELSE 'b2' END tag2 FROM table_name
I know the second code is incorrect but that is the logic I need. Thanks guys!