我绝不是编码员,所以我已经尝试过,但是失败了。
我想使用Google的Google Analytics(分析)Big Query Cookbook中的查询
购买产品A(增强型电子商务)的客户购买的产品
我粘贴了以下代码
进入标准SQL。
我做了几次尝试,但是倒下了,不是
先谢谢您 约翰
SELECT hits.product.productSKU AS other_purchased_products,
COUNT(hits.product.productSKU) AS quantity
FROM (
SELECT fullVisitorId, hits.product.productSKU, hits.eCommerceAction.action_type
FROM TABLE_DATE_RANGE([bigquery-public-data:google_analytics_sample.ga_sessions_],
TIMESTAMP('2017-04-01'), TIMESTAMP('2017-04-20'))
)
WHERE fullVisitorId IN (
SELECT fullVisitorId
FROM TABLE_DATE_RANGE([bigquery-public-data:google_analytics_sample.ga_sessions_],
TIMESTAMP('2017-04-01'), TIMESTAMP('2017-04-20'))
WHERE hits.product.productSKU CONTAINS 'GGOEYOCR077799'
AND hits.eCommerceAction.action_type = '6'
GROUP BY fullVisitorId
)
AND hits.product.productSKU IS NOT NULL
AND hits.product.productSKU !='GGOEYOCR077799'
AND hits.eCommerceAction.action_type = '6'
GROUP BY other_purchased_products
ORDER BY quantity DESC;
答案 0 :(得分:1)
以下内容在BigQuery Standard SQL中是完全等效的(没有任何优化,改进等-只是从旧版本到标准版本的纯转换)
accGrpDF
.select(col("partitionNumber"))
.where(col("accgrpid")===accGrpId)
.first()
.getInt(0)
显然会产生与旧版完全相同的结果