What would be the best way of doing this?
select 'blah' as foo,
CASE
WHEN foo='blah' THEN 'fizz'
ELSE 'buzz'
END as bar
As it is written right now I get an invalid column name 'foo' error. Is there anyway to do this where the select statement could be used as a view?
You need to use a nested select like this:
The problem is that the column foo is not recognized by the name in the same select statement.