title: Mysql get count of unique id that repeat in database
body: <p>let say I have the following table:</p>
  
  <pre><code>#hotel_id   #room_id     #price    
  3             4           50.00    
  3             5           45.00    
  3             6           50.00    
  4             5           45.00    
  4             7           50.00    
  4             8           45.00    
  5             4           45.00    
  5             8           50.00    
  5             9           45.00    
  </code></pre>
  
  <p>what query must I execute in order to get the number of unique #hotel_id - in this case it is 3,4,5 = 3 unique ids
  May sound simple , but... :) thank you in advance</p>
  
  ########### my query
  
  <pre><code>select 
      Count(Distinct a.id),
      rta.room_type_id,
      IF(SUM(price = 0), 0, SUM(price))
  from
      adverts a,
      rooms_to_adverts rta,
      room_types rt,
      prices_adverts pa
  where
      a.town = 'Sofia' and a.id = pa.advert_id
          and rta.room_type_id = rt.id
          and pa.room_type_id = rta.room_type_id
          and rta.advert_id = a.id
          and (pa.date &gt;= '2013-09-20'
          AND pa.date &lt; '2013-09-23')
          and rt.occupants &gt;= '1'
  GROUP BY a.id , rta.room_type_id
  order by a.id , rt.occupants ASC   
  </code></pre>
  
  <p>this query ouputs this
  <img src="https://i.stack.imgur.com/IhYn6.jpg" alt="enter image description here"></p>
  
  <p>LOOKS like it is not so simple :)</p>