I am working on my final project and this is the query that returns the list of all id’s, names and days.
select
c.id as id, i.full_name as n, day as d
from
(instructors i
inner join courses c ON c.instructor_id = i.id)
inner join exam_schedules e ON c.id = e.course_id
results samlpe:
id name day
9977 SCOTT, RAYMOND C. wednesday
9467 FERNANDEZ, CYNTHIA E. wednesday
9468 FERNANDEZ, CYNTHIA E. wednesday
9493 FERNANDEZ, CYNTHIA E. wednesday
9538 STEPHENS, RONNIE T. wednesday
9539 MYERS, RONNIE Y. wednesday
9554 GARRISON, EUGENE A. wednesday
How can I get the list of all ID’s and count of combinations of name+day ?
Example above should produce:
9977 1
9467 3
9468 3
9493 3
9538 1
9539 1
9554 1
I used temporary table for clarity. It is possible to merge this into one query, but it is very hard to do without the real schema: