title: Sub Query with Distinct
body: <p>I'm trying to get the distinct Area codes so I can filter the Top 5 within a report based on a week date range each time it has run. </p>
  
  <pre><code>  SELECT
          [Area] AS 'AreaCode',
          (SELECT COUNT(*) FROM gail_hazzards gh1 WHERE [gh1].[Area] = [gh].[Area]) AS 'AreaCount',
          CONVERT(DATE, gh.[Timetag1], 201) AS 'Time'
      FROM
        gail_hazzards gh
  
        GROUP BY gh.[Area], CONVERT(DATE, gh.[Timetag1], 201)
        ORDER BY AreaCount  DESC
  </code></pre>
  
  <p><strong>Results:</strong> I have been trying to add a sub query to get the distinct Area code but I'm having issues trying to get this to come out correctly :/</p>
  
  <pre><code>AreaCode    AreaCount   Time
  480            683     2016-03-23
  480            683     2016-03-24
  480            683     2016-03-25
  480            683     2016-03-29
  480            683     2016-03-30
  870            210     2016-04-15
  870            210     2016-04-16
  870            210     2016-04-19
  870            210     2016-04-20
  870            210     2016-04-21
  </code></pre>