title: Selecting COUNT(*) with DISTINCT
body: <p>In SQL Server 2005 I have a table <code>cm_production</code> that lists all the code that's been put into production. The table has a <code>ticket_number</code>, <code>program_type</code>, <code>program_name</code> and <code>push_number</code> along with some other columns.</p>
  <p>GOAL: Count all the DISTINCT program names by program type and push number.</p>
  <p>What I have so far is:</p>
  <pre><code>DECLARE @push_number INT;
  SET @push_number = [HERE_ADD_NUMBER];
  
  SELECT DISTINCT COUNT(*) AS Count, program_type AS [Type] 
  FROM cm_production 
  WHERE push_number=@push_number 
  GROUP BY program_type
  </code></pre>
  <p>This gets me partway there, but it's counting all the program names, not the distinct ones (which I don't expect it to do in that query). I guess I just can't wrap my head around how to tell it to count only the distinct program names without selecting them. Or something.</p>