I want to have a computed column that is true if the field asofdate is equal to the maximum asofdate in the table, otherwise false. I tried the following but I am getting a syntax error. What is the right way to do this?
select
case asofdate
when select max(asofdate) from sometable then 1
else 0
end
from sometable
Alternatively, is it possible to have a computed column along the lines of
case asofdate
when END OF PREVIOUS MONTH then 1
else 0
end
You cannot do it in an computed column, since the computed column can be only computed from the values of other columns in the same record.
You can do it in a view, instead:
Unfortunately, you cannot index this view.