I have the following query that I am trying to to run a COUNT/SUM and GROUP and just do not know enough to do it. I was hoping someone could help give me an idea on how to do it, syntax?
The query is:
SELECT
c.URL
, c.datetimecreated
, r.emailAddress
FROM Tracking c, recipients r
WHERE 1=1
AND c.recipientId = r.recipientId
AND c.broadcastId = <some id here>
The results set is:
ID DATETIMECREATED EMAILADDRESS URL
1 04-21-05 thisemail@email.com 2 04-21-05 thisemail@email.com 3 04-21-05 thisemail@email.com 4 04-21-05 thisemail@email.com 5 04-21-05 thisemail@email.com 6 04-21-05 anotheremail@email.com 7 04-21-05 anotheremail@email.com 8 04-21-05 anotheremail@email.com 9 04-21-05 anotheremail@email.com 10 04-21-05 anotheremail@email.com 11 04-21-05 anotheremail@email.com 12 04-21-05 anotheremail@email.com 13 04-21-05 anotheremail@email.com 14 04-21-05 anotheremail@email.com 15 04-21-05 thisemail@email.com 16 04-21-05 thisemail@email.com 17 04-21-05 thisemail@email.com 18 04-21-05 thisemail@email.com 19 04-21-05 thisemail@email.com 20 04-21-05 thisemail@email.com 21 04-21-05 thisemail@email.com 22 04-21-05 thisemail@email.com
Ideally, I would like to run the query where it would:
1) Group the URL and show total number of each URL. Similar to:
(Total 10)
(Total 21)
(Total 15)
2) Group each email and show the total clicks for that email address and the URLs clicked. For example:
thisemail@email.com (total URL clicks: 34)
URLs clicked:
anotheremail@email.com (total URL clicks: 42)
URLs clicked:
email@email.com (total URL clicks: 24)
URLs clicked:
3)Group the date and show the total number of clicks for that date and the URLs clicked
04-21-05 (Total Clicks 34)
URLs clicked:
Can anyone assist?
The query is:
SELECT
c.URL
, c.datetimecreated
, r.emailAddress
FROM Tracking c, recipients r
WHERE 1=1
AND c.recipientId = r.recipientId
AND c.broadcastId = <some id here>
The results set is:
ID DATETIMECREATED EMAILADDRESS URL
1 04-21-05 thisemail@email.com 2 04-21-05 thisemail@email.com 3 04-21-05 thisemail@email.com 4 04-21-05 thisemail@email.com 5 04-21-05 thisemail@email.com 6 04-21-05 anotheremail@email.com 7 04-21-05 anotheremail@email.com 8 04-21-05 anotheremail@email.com 9 04-21-05 anotheremail@email.com 10 04-21-05 anotheremail@email.com 11 04-21-05 anotheremail@email.com 12 04-21-05 anotheremail@email.com 13 04-21-05 anotheremail@email.com 14 04-21-05 anotheremail@email.com 15 04-21-05 thisemail@email.com 16 04-21-05 thisemail@email.com 17 04-21-05 thisemail@email.com 18 04-21-05 thisemail@email.com 19 04-21-05 thisemail@email.com 20 04-21-05 thisemail@email.com 21 04-21-05 thisemail@email.com 22 04-21-05 thisemail@email.com
Ideally, I would like to run the query where it would:
1) Group the URL and show total number of each URL. Similar to:
(Total 10)
(Total 21)
(Total 15)
2) Group each email and show the total clicks for that email address and the URLs clicked. For example:
thisemail@email.com (total URL clicks: 34)
URLs clicked:
anotheremail@email.com (total URL clicks: 42)
URLs clicked:
email@email.com (total URL clicks: 24)
URLs clicked:
3)Group the date and show the total number of clicks for that date and the URLs clicked
04-21-05 (Total Clicks 34)
URLs clicked:
Can anyone assist?