title: SQL/SQL-LITE - Counting records after filtering
body: <p>Suppose I have a table of customers and a table of sales order with the following schemas:</p>
  
  <ol>
  <li>Customer = {id, name} </li>
  <li>Sales_order = {id, customer_id, sales_representer}</li>
  </ol>
  
  <p>With the following defintions :</p>
  
  <ol>
  <li>id is a primary key in both tables.</li>
  <li>customer_id is a foriegn key references customer.</li>
  </ol>
  
  <p>I want to implement the following query :</p>
  
  <pre><code>For any customer whose sales_representer is 100, find the customer id, 
  customer name and the number of his overall orders.
  </code></pre>
  
  <p>I built the following query:</p>
  
  <pre><code>select C.id, C.name, count(C.id)
  from customer C, sales_order S
  where   C.id = S.customer_id and 
          S.sales_represntor = '100'
  group by C.id, C.nname;
  </code></pre>
  
  <p>But as a result of count(C.id) I get only the number of sales whose the sales_representer is 100. 
  I know I can add another instance of sales_order (i.e. S2) and count from it but It seems to me not efficent at all. </p>
  
  <p>Do anyone have a solution ?</p>
  
  <p>Thank you</p>