hive Expression Not In Group By Key>我在hive中创建了一个表。它有以下列:
id bigint, rank bigint, date string
我想要得到每月的平均排名。我可以使用这个命令。它的工作原理。 p>
select a.lens_id, avg(a.rank)
from tableA a
group by a.lens_id, year(a.date_saved), month(a.date_saved);
但是,我还想要得到日期信息。我使用这个命令:
select a.lens_id, avg(a.rank), a.date_saved
from lensrank_archive a
group by a.lens_id, year(a.date_saved), month(a.date_saved);
它报错:Expression Not In Group By Key
回答:
完整错误消息的格式应为Expression Not in Group By Key [value]。
[value]
会告诉你需要在
的组中是什么表达式。仅看这两个查询,我认为您需要显式地将a.date_saved添加到Group By中。
问题:是的。添加了a.date_saved之后,它就工作了。然而,它并没有做到我想要的。我想要一个月的平均薪资。现在它不做平均。它只显示了通过a.date_saved添加组之后的所有记录。
回答:
您不能选择一个列,并且不按照该列进行分组。如果您想要显示a.date_saved,您需要根据它进行分组。你可以显示year(a.date_saved)和month(a.date_saved),因为它们在组中,但不是100%
解决方案二:
走动是将额外的字段在collect_set并返回集合的第一个元素。例如 p>
select a.lens_id, avg(a.rank), collect_set(a.date_saved)[0]
from lensrank_archive a
group by a.lens_id, year(a.date_saved), month(a.date_saved);
– customer unit price (including reject), in HQL, in select… Group by… To display a field in>, you must group by that field, otherwise do not select that field
select user_id,sum(order_money)/count(order_money) from us_order;
error:
modified answer:
select user_id,sum(order_money)/count(order_money) from us_order group by user_id;
select collect_set(user_id)[0],sum(order_money)/count(order_money) from us_order;
Read More:
- Error Code: 1055. Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated
- Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and co
- Group by operator of hive execution plan
- Group by query only_ FULL_ GROUP_ By error
- SQL query time group_ Was cut by group_ CONCAT()
- Solution to errors reported by TES command in vscode – errors reported by typescript command
- Process of checking the error of connection reset by peer reported by reactor netty
- A simple method of generating secret key by GIT and configuring SSH public key
- Error: more than one row returned by a subquery used as an expression
- Error reported by gulp: referenceerror: primordials is not defined
- Common errors reported by Eureka in spring cloud
- Error reported by nested installation esxi host in vsan environment
- Exception on start hive: caused by: java.net.noroutetohostexception: no route to host
- How to Fix error reported by rqt_plot tool in ROS
- Python Anaconda Spyder can’t display pictures by using Matplotlib. Error report solution: figures now render in the plots pane by default. To mak
- Invalid archiveerror reported by CONDA
- It’s been pitiful by was. It’s reported in the following webapp.WebApp Logerror srve0293e: [servlet error] – [null] error.
- How to deal with the error reported by live mail
- Caused by the “error string in namespace std does not name a type” error
- When react dynamically prunes components by operating arrays, the state of the remaining components is not preserved. Solution to the problem (method of dynamically setting unique key value)