我正在尝试在 SQL Server 2012 Express 中添加一个自动计算的字段,该字段通过使用以下方法计算日期差异来存储项目完成的百分比:
ALTER TABLE dbo.projects
ADD PercentageCompleted AS (select COUNT(*) FROM projects WHERE project_finish > project_start) * 100 / COUNT(*)
但我收到此错误:
Msg 1046, Level 15, State 1, Line 2
Subqueries are not allowed in this context. Only scalar expressions are allowed.
我究竟做错了什么?