I have an email campaign where some people only clicked on the tracked link ABC in the email . Other people clicked on both tracked links, ABC and XYZ.
Is it possible to produce a Report with the right set of âConditionsâ so that the results only show those people who ONLY clicked the ABC link?
I want to restrict the report results so that anyone who clicked BOTH the ABC and XYZ links doesnât show in the report.
Is this beyond the capabilities of Suiteâs Report module or am I not smart enough to create the correct conditions?
Find an work example using sql query once Reports can not reach such request:
SELECT
cl.campaign_id,
cl.target_type,
cl.target_id,
cl.related_id,
(
SELECT COUNT() num FROM campaign_trkrs cta WHERE cta.id = ct.id AND ct.id = â401f8c24-04b9-11ea-ba1f-022c40d974e6â
) abc,
(
SELECT COUNT() num FROM campaign_trkrs cta WHERE cta.id = ct.id AND ct.id = â63fc1504-04b9-11ea-bfee-069e4f790264â
) xyz
FROM campaign_log cl
INNER JOIN campaign_trkrs ct ON cl.related_id = ct.id
WHERE cl.activity_type = âlinkâ AND cl.deleted = 0
HAVING abc > 0 AND xyz = 0;
Many thanks for the code. However, Iâm getting an error and Iâm at the limit of my SQL knowledge!:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') num FROM campaign_trkrs cta WHERE cta.id = ct.id AND ct.id = â153abe38-b8b1-5bâ at line 7
If I add an asterisk [COUNT(*)] then the query returns those people who clicked the â153abeâŚâ link but the results also include those people who clicked the â24bfâŚâ link.
I only want those ID who clicked â153âŚâ and didnât click â24bfâŚâ
Whatâs the purpose of ânumâ on lines 7 and 10?
I just read about mysql HAVING and it doesnât make sense to me! It compares the rows of âabcâ and âxyzâ and only returns the rows where the contact.id exists in âabcâ but doesnât exist in âxyzâ? How it does that?!
Think of HAVING as the WHERE that happens after the aggregated functions (COUNT).
So you use WHERE to restrict which records go into the COUNT,
and then you use HAVING to restrict which lines with aggregated values get displayed in the end result.