title: How can I get customer data based on the number of users they have?
body: <p>I want to get customer data from all the businesses with more than 1 user. </p>
  
  <p>For this I think I need a subquery to count more than 1 user and then the outer query to give me their emails. </p>
  
  <p>I have tried subqueries in the WHERE and HAVING clause</p>
  
  <pre><code>SELECT   u.mail
  FROM     users u
  WHERE    count IN (
      SELECT count (u.id_business)
      FROM businesses b
      INNER JOIN users u ON b.id = u.id_business
      GROUP BY b.id, u.id_business
      HAVING COUNT (u.id_business) &gt;= 2
  )
  </code></pre>