123 /point 022-04-03T11:26:13.719000123 /point 2022-04-03T11:27:15.653820 123 /point ad 2022-04-03T111:34:100000 123 指向下一个22022-04-03T12:38:15.82340 123 /point 2022-04-03T12:50:18123820
我在BigQuery中编写查询,试图导出会话访问的不同页面,按照访问页面的时间(PageVisit_time(顺序(升序(,下面是我编写的内容和输出:
SELECT DISTINCT
fullVisitorId||'.'||visitStartTime||'.'||visitNumber AS session_id,
page.pagePath,
MIN(DATETIME_ADD(DATETIME(TIMESTAMP_SECONDS(visitStartTime),"America/New_York"), INTERVAL hits.time MILLISECOND)) AS PageVisit_time
from `xx.xx.ga_sessions_*`,
UNNEST(hits) AS hits
WHERE hits.type = "PAGE"
and date = '20220403'
group by 1,2
order by 1, 3 desc
上述查询的输出:
页面路径如果我没有错,您希望获得会话中每个pagePath的第一行,以及这些事件的其他属性
如果我是正确的,您可以使用array_agg函数来获得您想要的第一行。我在这里简化了查询,所以您可以根据需要进行修改。
SELECT
fullVisitorId||'.'||visitStartTime||'.'||visitNumber AS session_id,
page.pagePath,
array_agg(struct(
visitStartTime,
attribute1,
attribute2,
attribute
) order by visitStartTime limit 1)[offset(0)] as attr
from `xx.xx.ga_sessions_*`,
UNNEST(hits) AS hits
WHERE hits.type = "PAGE"
and date = '20220403'
group by 1,2
order by session_id, attr.visitStartTime