title: Msg 512, Level 16 Error
body: <p>How can I solve the following problem?</p>
  
  <blockquote>
    <p>Msg 512, Level 16, State 1, Line 1 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. The statement has been terminated.</p>
  </blockquote>
  
  <p>I try to get the Frequency like:</p>
  
  <pre><code>| Frequency
  | 19
  | 23
  </code></pre>
  
  <p>But somehow I can't get more than I value by firing this Query:</p>
  
  <pre><code>SELECT ts.TimeDifference/ ts.EntryAmount as Frequency
  FROM
  (
      SELECT COUNT(*) as EntryAmount,
      (
          SELECT DATEDIFF(d, t.minimum, t.maximum)
          FROM (SELECT max(Date) AS maximum, min(Date) AS minimum FROM Times GROUP BY column1, column2, column3, column4 HAVING COUNT(*) &gt; 1) t
      ) AS TimeDifference
      FROM Times
  ) ts
  </code></pre>
  
  <p>Thank you.</p>