我已经在bigdata中编写了这样的查询,以显示平均会话。
select dd, mm, SUM(total_sessions) AS Total_Sessions, AVG(sess_length_seconds) AS Average_Session_Duration from (
SELECT dd, mm, user_pseudo_id, sess_id, MIN(min_time) sess_start, MAX(max_time) sess_end, COUNT(*) records,
MAX(sess_id) OVER(PARTITION BY user_pseudo_id) total_sessions,
(ROUND((MAX(max_time)-MIN(min_time))/(1000*1000),1)) sess_length_seconds
FROM (
SELECT *, SUM(session_start) OVER(PARTITION BY user_pseudo_id ORDER BY min_time) sess_id
FROM (
SELECT *, IF(previous IS null OR (min_time-previous) > (20*60*1000*1000), 1, 0) session_start
FROM (
SELECT *, LAG(max_time, 1) OVER(PARTITION BY user_pseudo_id ORDER BY max_time) previous
FROM (SELECT EXTRACT(MONTH FROM TIMESTAMP_MICROS(event_timestamp)) as mm, EXTRACT(DAY FROM TIMESTAMP_MICROS(event_timestamp)) as dd, user_pseudo_id, MIN(event_timestamp) AS min_time, MAX(event_timestamp) AS max_time
FROM `alive-ios.analytics_160092165.events_201810*`
GROUP BY mm, dd, user_pseudo_id)
)
)
)
GROUP BY 1, 2,3, 4
ORDER BY 1, 2
)
GROUP BY dd, mm
ORDER BY dd, mm desc
LIMIT 10
问题在data studio中,它只有选项“ sum”或“ average”等。因此,它不显示单个行,而是始终显示组合结果。如何显示单个行?
答案 0 :(得分:0)
在Data Studio中,您应该将其作为维度而非指标。