Hi Team,
I want the data for every urlHost with metrics like Sessions,Page Views, Bounces and Sum of Page Pings. The query I am writing is giving me the wrong data(cartesian product I think) can you guys please validate my query.
SELECT t1.page_urlhost,
Count (1) AS "number_of_events" ,
Sum(domain_sessionidx) sessions ,
tbl1.sumbounces AS bounce,
(
SELECT Count(event)
FROM atomic.events AS ent
WHERE ent.event='page_view'
AND t1.page_urlhost=ent.page_urlhost
AND collector_tstamp > CURRENT_DATE - integer '7' ) AS page_view,
(
SELECT count(event)
FROM atomic.events AS ent
WHERE ent.event='page_view'
AND t1.page_urlhost=ent.page_urlhost
AND collector_tstamp > CURRENT_DATE - integer '7' ) AS page_ping
FROM atomic.events t1
INNER JOIN
(
SELECT page_urlhost ,
sum(bounces) AS sumbounces
FROM (
SELECT page_urlhost,
domain_userid,
CASE
WHEN count (domain_userid)>1 THEN '0'
ELSE '1'
END AS bounces
FROM atomic.events
WHERE collector_tstamp > CURRENT_DATE - integer '7'
GROUP BY page_urlhost,
domain_userid)
GROUP BY page_urlhost ) AS tbl1
ON tbl1.page_urlhost=t1.page_urlhost
GROUP BY t1.page_urlhost,
tbl1.sumbounces limit 1000;
Appreciate your help.
Thanks!