I have two tables
table J:
P_ID event T_ID URL
8187 6 14690481058450526 maplestage.com
8187 6 14690481058450527 maplestage.com
Table A:
P_ID event T_ID URL
8187 7 14690481058450526 NULL
8187 7 14690481058450526 NULL
8187 7 14690481058450527 NULL
I have the following query to count the event that are 6 and events that are 7:
SELECT sum(if(j.event=6,1,0)) Type1, j.P_ID, j.URL, sum(if(a.event=7,1,0)) Type2 FROM Tabel_J j LEFT outer join Table_A a on a.T_ID = j.T_ID GROUP BY j.P_ID, j.URL;
The result i am getting is this:
Type1 P_ID URL Type2
3 8187 maplestage.com 3
The result i want to get is:
Type1 P_ID URL Type2
2 8187 maplestage.com 3
Please can someone help me with this.
Thanks