我想使用我在Google Analytics(分析)的数据集中找到的某些标准从我的BigQuery中过滤掉NHT。对于我的示例,我希望过滤掉这两组标准:
networkLocation REGEXP_Contains (r"^(ovh \(nwk\)|hostwinds llc.|bhost inc|prisma networks llc|psychz networks|buyvm services|private customer|secure dragon llc.|vmpanel|netaction telecom srl-d|hostigation|frontlayer technologies inc.|digital energy technologies limited|owned-networks|rica web services|netaction telecom srl-d|hurricane electric inc.|private customer - host.howpick.com|ssdvirt|sway broadband|detect network|gorillaservers inc.|micfo llc.| netaction telecom srl|egihosting|zenlayer inc|intercom online inc.|gs1 argentine|ovh hosting inc.|vps cheap inc.|limeip networks|blackhost ltd.|amazon.com inc.)$")
AND
device.browserVersion REGEXP_Contains(r"^(41.0|55.0)$")
OR
networkLocation REGEXP_Contains ("^(hpro group ltd)$")
AND
device.browserVersion REGEXP_Contains("45.0")
我的SQL:
SELECT
channelGrouping,
date,
h.page.pagePath AS Page,
SUM(totals.timeOnSite) AS Session_Duration,
SUM(totals.visits) AS Visits,
AVG(totals.timeonSite/totals.visits) AS Avg_Time_per_Session,
SUM(totals.bounces) AS Bounce,
(SUM(totals.bounces)/SUM(totals.visits)) AS Bounce_rate,
geoNetwork.networkLocation,
device.browserVersion,
device.browser
FROM
`93868086.ga_sessions_*`,
UNNEST(hits) as h
WHERE
_TABLE_SUFFIX BETWEEN FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 365 DAY))
AND FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY))
GROUP BY
date,
channelGrouping,
geoNetwork.networkLocation,
device.browserVersion,
device.browser,
h.page.pagePath
我需要一个HAVING NOT子句,但是我不确定如何对我需要过滤掉条件的那组语句进行分组。任何帮助都会很棒!
答案 0 :(得分:1)
假设您的条件表达式正确-下面应该是一种方法
HAVING NOT (
(
REGEXP_CONTAINS (networkLocation, r"^(ovh \(nwk\)|hostwinds llc.|bhost inc|prisma networks llc|psychz networks|buyvm services|private customer|secure dragon llc.|vmpanel|netaction telecom srl-d|hostigation|frontlayer technologies inc.|digital energy technologies limited|owned-networks|rica web services|netaction telecom srl-d|hurricane electric inc.|private customer - host.howpick.com|ssdvirt|sway broadband|detect network|gorillaservers inc.|micfo llc.| netaction telecom srl|egihosting|zenlayer inc|intercom online inc.|gs1 argentine|ovh hosting inc.|vps cheap inc.|limeip networks|blackhost ltd.|amazon.com inc.)$")
AND REGEXP_CONTAINS(device.browserVersion, r"^(41.0|55.0)$")
) OR (
REGEXP_CONTAINS (networkLocation, r"^(hpro group ltd)$")
AND REGEXP_CONTAINS(device.browserVersion, r"45.0")
)
)