title: How can I make two condition in having clause
body: <p>I have a table similar to:</p>
  
  <pre><code>domain      |   file      | Number 
  ------------------------------------     
  aaa.com     | aaa.com_1   | 111
  bbb.com     | bbb.com_1   | 222
  ccc.com     | ccc.com_2   | 111
  ddd.com     | ddd.com_1   | 222
  eee.com     | eee.com_1   | 333
  </code></pre>
  
  <p>I need to query the number of <code>Domains</code> that share the same <code>Number</code> and their <code>File</code> name ends with <code>_1</code>. I tried the following:</p>
  
  <pre><code>select count(domain) as 'sum domains', file
  from table 
  group by Number
  having
  count(Number) &gt;1 and File like '%\_1'; 
  </code></pre>
  
  <p>It gives me:</p>
  
  <pre><code>sum domains | file
  ------------------------------
  2           | aaa.com
  2           | bbb.com
  </code></pre>
  
  <p>I expected to see the following:</p>
  
  <pre><code>sum domains | file
  ------------------------------
  1           | aaa.com
  2           | bbb.com
  </code></pre>
  
  <p>Because the <code>Number</code> 111 appears once with <code>File</code> ends with <code>_1</code> and <code>_2</code>, so it should count 1 only. How can I apply the 2 conditions that I stated earlier correctly ?</p>