title: SQLServer Subquery units as column
body: <p>I'm trying to get a subquery as a column with a condition.</p>
  
  <p>The error I get from SQL Server is:</p>
  
  <p><strong>Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, &lt;, &lt;= , >, >= or when the subquery is used as an expression.</strong></p>
  
  <p>There are a bunch more columns I'm selecting, but here is the main query that is giving ma an error: </p>
  
  <pre><code>SELECT ItemNo, Channel, Brand, TotalUnits,
         (SELECT TotalUnits FROM Table1 WHERE Locked = 1) As LockedUnits
  FROM Table1
  </code></pre>
  
  <p><em>EDIT: Locked is a 0 or 1 value</em></p>
  
  <p>Ideally the query would return this (LockedUnits is always a subset of TotalUnits):</p>
  
  <pre><code>ItemNO   Channel   Brand    TotalUnits    LockedUnits
  1        5         Adidas   100           80
  2        7         Nike     500           360
  </code></pre>