I have the following tables:
s2s_actions
id app_id brand_id country_id
------ ------ -------- ----------
22 15 361 5
29 15 361 5
35 15 7 64
40 15 7 64
41 15 37 5
44 15 361 5
clicks
id app_id country_id brand_id
------ ------ ---------- --------
103 15 5 361
104 15 64 7
105 15 5 37
106 15 5 37
Is it possible to have a query that groups s2s_actions by brand_id,country_id,app_id and counts the number of clicks for each group?
in that case, results should be:
app_id country_id brand_id total_clicks
------ ---------- -------- ------------
15 5 361 1
15 64 7 1
15 5 37 2
Thanks!
2
Answers
You can use a simple group by followed by a correlated sub-query:
This is an option using
inner join
:Results :
Demo here