title: creating SQL query using aliases and COUNT
body: <p>Please help me to create a query using aliases and COUNT. I have <strong>only one table</strong>, which contains all the necessary information but since I have to use COUNT to get the number of persons included in the final result, unfortunately I`m forced to use aliases as I understand. </p>
  
  <p>I have companies, cities and persons working in these companies.
  As a result I have to have the number of people working in every company in every city.
  Initially I tried this:</p>
  
  <pre><code>SELECT COUNT (employee_name) FROM (SELECT company_city_name, company_name FROM mytable)
  </code></pre>
  
  <p>Here I get the error saying I have to use aliases. </p>
  
  <p>I also tried to combine "SELECT COUNT (employee_name) FROM mytable" and "SELECT company_city_name, company_name FROM mytable" (since these two queries are working separately):</p>
  
  <pre><code>SELECT COUNT (employee_name)
  FROM mytable AND SELECT company_city_name, company_name FROM mytable
  </code></pre>
  
  <p>Not working, get an error. I still don<code>t understand why I can</code>t use AND to make it work. Anyway, with aliases I`m totally confused. I have something like this:</p>
  
  <pre><code>SELECT COUNT (employee_name)
  FROM (SELECT company_city_name AS city_name, company_name AS company FROM mytable AS t1)
  </code></pre>
  
  <p>Where am I going wrong here? </p>