I want to add an extra column. This extra column will get a value based on a case statment. My objective is for instance, although the syntax is very wrong, something to accomplish this: When 'A' then 'Apple' AND 'ExtraColumn'=1. I have tried to create an equvialnt to this using the code below, but I get an error that my SQL syntax is incorrect.
select Patient,
case ColumnName
when 'A' then 'Apple'
when 'B' then 'Banana'
end ColumnName,
case ExtraColumn
when 'A' then '1'
when 'B' then '2'
end ExtraColumn,
ColumnResult
from TABLE
unpivot
(
ColumnResult
for ColumnName in (COL1,COL2,COL3)
for ExtraColumn in (COL1,COL2,COL3)
)u