title: tsql distinct having count
body: <p>I am using SSMS 2008 and am trying to select count of consumers who are part of two different events.  Probably this is a simple query, but it is currently not returning expected count.  Here is my T-SQL code which better explains what I tried:</p>
  
  <pre><code>select [Program Quarter], event_name, consumer
  from #consumer_initiations
  where [Program Quarter] = 1  --and consumer = 'Byrd, Victoria Lynn'
  group by [Program Quarter], event_name, consumer
  having count (distinct event_name) &gt; 1
  </code></pre>
  
  <p>So this query above returns 0 records.  if I run following query, I get all records:</p>
  
  <pre><code>select [Program Quarter], event_name, consumer
  from #consumer_initiations
  where [Program Quarter] = 1
  </code></pre>
  
  <p>So I can see where some of these records are where there is same quarter, same person, but 2 or more events for that person.  Now, how can I count number of times that same person is part of 2 or more events?</p>