I'm trying to run the following Query:
create table MyTable (
TableIndex bigint primary key identity(1,1) not null,
ForeignKey1 int not null,
ForeignKey2 char(16) not null,
fldSomeNumber float(24),
fldScore as cast(case
when fldSomeNumber is null or fldCSIPercentage=0 then 0
when fldSomeNumber <= 0.09 then (select fldTenthScore from tblScores where ScorePrimaryKey=MyTable.ForeignKey2)
when fldSomeNumber <= 0.9 then (select fld1Score from tblScores where ScorePrimaryKey=MyTable.ForeignKey2)
...
else 100 end as float(24))
);
But I keep getting the following error: "Subqueries are not allowed in this context. Only scalar expressions are allowed." Is it not possible to put sub-selects within a calculated column like this?
I'm running SQL Server Express 2016.