title: Calculating the percentage of dates (SQL Server)
body: <p>I'm trying to add an auto-calculated field in SQL Server 2012 Express, that stores the % of project completion, by calculating the date difference by using:</p>
  
  <pre><code>ALTER TABLE dbo.projects
  ADD PercentageCompleted AS (select COUNT(*)  FROM projects WHERE project_finish &gt; project_start) * 100 / COUNT(*)
  </code></pre>
  
  <p>But I am getting this error:</p>
  
  <pre><code>Msg 1046, Level 15, State 1, Line 2
  Subqueries are not allowed in this context. Only scalar expressions are allowed.
  </code></pre>
  
  <p>What am I doing wrong?</p>