gpt4 book ai didi

SQL Hive 子查询错误

转载 作者:可可西里 更新时间:2023-11-01 15:24:25 25 4
gpt4 key购买 nike

我有下面的查询

set hive.cli.print.header=true;
set hive.query.max.partition=1000;
set hive.mapred.mode=unstrict;

SELECT

dim_lookup("accounts",name,"account_id") = '28016' as company,
dim_lookup("campaigns",name,"campaign_id") in (117649,112311,112319,112313,107799,110743,112559,112557,105191,105231,107377,108675,106587,107325,110671,107329,107181,106565,105123,106569,106579,110835,105127,105243,107185,105211,105215) as campaign_name,
case when is_click_through=0 then "PV" else "PC" end as conv_type,
(SELECT COUNT(1) FROM impressions WHERE ad_info[2] in (117649,112311,112319,112313,107799,110743,112559,112557,105191,105231,107377,108675,106587,107325,110671,107329,107181,106565,105123,106569,106579,110835,105127,105243,107185,105211,105215)) AS impressions

FROM actions

WHERE
data_date>='20170101'
AND data_date<='20171231'
AND conversion_action_id in (20769223,20769214,20769219,20764929,20764932,20764935,20769215,20769216,20764919,20769218,20769217,20769220,20769222)
GROUP BY conv_type

当我执行它时出现错误

 ERROR ql.Driver: FAILED: ParseException line 8:1 cannot recognize input near 'SELECT' 'COUNT' '(' in expression specification

我正在尝试获取指定 conversion_action_id 的每次展示次数。我的查询可能有什么错误?感谢您的帮助。

仅供引用:ad_info[2] 和 campaign_id 相同。

最佳答案

问题很明显,您的 SELECT 中有一个子查询。

这不是它的工作原理。

不幸的是,确切的解决方案不是那么清楚,因为我不完全确定你想要什么,但这里有一些一般性建议:

  1. 编写你的子查询,测试它并确保它没问题
  2. 与其将其放在您的 SELECT 部分,不如将其放在您的 FROM 部分,并且(一如既往)从 FROM 中选择

只需将您的子查询输出视为可以在 from 语句中使用的另一个表,并且需要将其与 from 语句中的其他表组合(JOIN、UNION?)。

关于SQL Hive 子查询错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48869837/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com