My knowledge of complex MySQL queries is not good and I'm having trouble searching or even phrasing this question.
I have a table that looks as follows.
 
 
I have a query that counts all the rows where 'type = student' and then groups those by year and month for which I use the created_column. This is pretty straightforward.
Query looks like this:
SELECT YEAR(created_at) as year, MONTH(created_at) as month, COUNT(type) as student_count
FROM users
WHERE type = "student"
GROUP BY year, month
ORDER BY year, month
I now need to add 2 more columns, 'subscription' & 'pay_per_video' which will further divide the total count for each month and year into student level type either 'subscription' OR 'pay_per_video'. Eg. if in Jan 2017 a total of 20 students registered. 12 might be per_per_video students while 8 in that month were subscription students. Any pointers are greatly appreciated.
UPDATE What I'm looking for is something like this: Table: Subject_Selection
Year    Month       Student Count     Pay Per View     Subscription
--------------------------------------------------------------------
2016     12              20                 20               0
2017     1               23                 12              11
2017     2               30                 10              20
2017     3                2                  1               1
2017     4               12                  2              10
2017     5               90                 40              50
2017     6               12                  0              12
 
     
     
    