I have the following table:
| campaign_id | source_id | clicked | viewed |
----------------------------------------------
| abc | xxx | 0 | 0 |
| abc | xxx | 1 | 0 |
| abc | xxx | 1 | 1 |
| abc | yyy | 0 | 0 |
| abc | yyy | 1 | 0 |
| abc | yyy | 1 | 1 |
| abc | yyy | 0 | 0 |
I need the following output:
xxx > Total: 3 // Clicked: 2 // Viewed 1
yyy > Total: 4 // Clicked: 2 // Viewed 1
I know that I have to use some sort of SUM() in my query, but I don't know how to differ between those multiple unique values in the source_id (something like foreach, idk).
How can I get such an output which shows stats from all unique source_ids by using only one query?