title: Selecting MAX from a COUNT
body: <p>It's been a couple of years since I have had to do some more complicated SQL and I'm a bit rusty. I need to select a <code>max(count())</code>, but I have recently re-learned that you can't nest aggregate functions.</p>
  
  <p>I am using WebSQL and have a Table called "calls".</p>
  
  <pre><code>Calls
    id INT
    targetId INT
    date DATETIME
  </code></pre>
  
  <p>I need to select the maximum COUNT of the target id. So far I have this: </p>
  
  <pre><code>SELECT targetId, COUNT(targetId) AS NumberOfCalls FROM calls GROUP BY targetId
  </code></pre>
  
  <p>This is returning to me the number of times each target has been called. I need to dynamically build a report around this and will need to know the highest value that any of the targetIds have</p>
  
  <p>I tried this but it isn't working and returns no data to me whatsoever:</p>
  
  <pre><code>SELECT MAX(x.count) FROM (SELECT COUNT(targetId) AS count FROM calls GROUP BY targetId)   x
  </code></pre>
  
  <p>If anyone could help me out, it'd be greatly appreciated! </p>