bigquery上的URL漏斗

时间:2016-02-24 10:45:05

标签: sql google-bigquery

我正在尝试通过网址建立渠道。但我的请求以错误结束:“错误:无法按聚合分组。” 所以,这是请求:

SELECT
COUNT(DISTINCT s1.clientId ) AS s1.User,
s1.page.pagePath
FROM (
SELECT
COUNT(DISTINCT clientId ) as User,
page.pagePath
FROM
[89437389479847487]
GROUP BY user,page.pagePath
HAVING
page.pagePath = 'URL 1'
AND page.pagePath != 'utm'
) AS s1
INNER JOIN (
SELECT
COUNT(DISTINCT clientId ) AS User,
page.pagePath
FROM
[89437389479847487]
GROUP BY user,page.pagePath
HAVING
page.pagePath = 'URL 2'
AND page.pagePath != 'utm') AS s2
ON 
s1.User=s2.User
GROUP BY s1.user,s1.page.pagePath

哪里可能是个错误?感谢。

更新:我修复了请求,但仍然有错误:

SELECT 
  COUNT(DISTINCT s1.clientId ) Auser ,
  s1.page.pagePath
FROM (
  SELECT
    COUNT(DISTINCT clientId ) AS user ,
    page.pagePath
  FROM
    [limetest.limetableempty]
  WHERE
    page.pagePath CONTAINS '/internet/calc2/'
    AND page.pagePath != 'utm_'
  GROUP BY page.pagePath
) s1
INNER JOIN (
  SELECT 
    COUNT(DISTINCT clientId ) AS user,
    page.pagePath
  FROM
    [limetest.limetableempty]
  WHERE
    page.pagePath CONTAINS '/help/'
    AND page.pagePath != 'utm_' AND page.pagePath != 'utm_' 
  GROUP BY 
page.pagePath) s2
ON
s1.clientId=s2.clientId
    GROUP BY s1.page.pagePath

错误:“找不到字段'clientId'”。 我正在尝试在两个网址之间建立转换渠道('/ internet / calc2 /'和'/ help /').

1 个答案:

答案 0 :(得分:0)

根据您问题中的可用信息,我建议尝试以下内容:

SELECT 
  s1.page,
  COUNT(s1.clientId ) AS usersAtFunnelStart,
  COUNT(s2.clientId ) AS usersAtFunnelEnd
FROM (
  SELECT
    page.pagePath AS page,
    clientId
  FROM
    [limetest.limetableempty]
  WHERE
    page.pagePath CONTAINS '/internet/calc2/'
    AND page.pagePath != 'utm_'
  GROUP BY 1, 2
) s1
LEFT JOIN (
  SELECT 
    clientId
  FROM
    [limetest.limetableempty]
  WHERE
    page.pagePath CONTAINS '/help/'
    AND page.pagePath != 'utm_' 
  GROUP BY 1
) s2
ON s1.clientId = s2.clientId
GROUP BY s1.page