Time Spent Per Page View - Downstream
Hi All,
I'm trying to calculate Time Spent Per Page View in our Downstream Data Lake. I was referencing the Data Columns reference to try to understand this, but unsure how to calculate it in SQL. It's my understand each row is a hit. How would I look at the average time spent on a particular page to exclude single page visits and also to average the time on a specific page, for example "Page A"? I'm trying to replicate this from my calculated metric that contains a segment as well downstream. I posted it here to reference.

I am also trying to combine this with this time spent code: Sample SQL queries to query Adobe analytics Data feeds
SELECT CONCAT(post_visid_high, post_visid_low, visit_num, visit_start_time_gmt) as visit_id,
visit_page_num,
post_cust_hit_time,
CASE
WHEN LEAD(visit_id) OVER (ORDER BY CONCAT(post_visid_high, post_visid_low, visit_num, visit_start_time_gmt), visit_page_num) = visit_id AND LEAD(visit_page_num) OVER (ORDER BY CONCAT(post_visid_high, post_visid_low, visit_num, visit_start_time_gmt), visit_page_num) > visit_page_num
THEN LEAD(post_cust_hit_time) OVER (ORDER BY CONCAT(post_visid_high, post_visid_low, visit_num, visit_start_time_gmt), visit_page_num) - post_cust_hit_time
ELSE NULL
END as time_spent
FROM your_data_feed_name
WHERE date >= 'your_start_date'
AND date <= 'your_end_date'
