I have got 2 tables: Institute & Course
Institute
---------
i_id i_name i_city
------ -------- --------
1 Name 1 London
2 Name 2 Manchester
3 Name 3 London
Course
-------
c_id i_id stream
------ ------- --------
1 1 Engineering
2 1 Engineering
3 2 Engineering
4 3 Engineering
Now I am trying to achieve 3 things:
a) Number of Institutes per city offering Engineering courses. b) Total (distinct) Number of Institutes offering Engineering courses.
I started writing below query to achieve this:
SELECT institute.i_city,
COUNT( DISTINCT institute.i_id ) AS institute_count_per_city
FROM institute, course
WHERE institute.i_id = course.i_id
AND course.stream = 'Engineering'
GROUP BY institute.i_city
I got below result:
i_city institute_count_per_city
------- -------------------------
London 2
Manchester 1
Now I have achieved the count of institutes per city.
I can't figure how can I get the total number of institutes in same query which in the above example will be 3 (2+1)
I would really appreciate the help.