title: SQL Inner Join customers with orders
body: <p>if I have a two tables (one of customers, with their information including address, name, emails etc) and another of orders (with order number, shipping date, customer name who ordered that item), how could I show the email of the customers who have less than 3 orders?</p>
  
  <p>I know I have to use an inner join and some alias's, but i'm not sure how to proceed.</p>
  
  <p>Thanks!</p>
  
  <p>what I have so far:</p>
  
  <pre><code>SELECT customer.email 
  FROM customer as cust 
  INNER JOIN (select customer_id, sum(line_qty) AS total 
              from orders as o ON cust.customer_id = o.customer_id 
              where total = (SELECT total &lt; 3 
                             FROM (select customer_id, sum(line_qty) AS total 
                                   from orders as o ON cust.customer_id = o.customer_id
                                  ) as sub);
  </code></pre>