我正在尝试在使用聚合和 groupby 函数的 Apache Phoenix 中执行查询。我已经在 mysql 中执行了相同的查询并且它可以工作,但是在凤凰城我尝试了基于 mysql 查询的查询,但它失败了。请参阅下面的 mysql 查询和 Phoenix 查询。
MySQL:
select id3, id4, name, descr, status, min(date) from table1
where status = "inactive" group by id3, id4, name, descr, status
结果:
id3 id4 名称描述状态 min(date)
17773 8001300701101 name1 descr1 INACTIVE 20121202
17785 9100000161822 name3 descr3 INACTIVE 20121201
凤凰查询:
MySQL和Phoenix的查询没有区别。
select id3, id4, name, descr, status, min ( date ) from table1
WHERE status = 'inactive' group by id3, id4, name, descr, status;
但是我收到以下错误有人可以解释一下吗?
Error: ERROR 1018 (42Y27): Aggregate may not contain columns not in GROUP BY. ELS_NAME (state=42Y27,code=1018)
java.sql.SQLException: ERROR 1018 (42Y27): Aggregate may not contain columns not in GROUP BY. ELS_NAME
at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:361)
at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:133)
at org.apache.phoenix.compile.ExpressionCompiler.throwNonAggExpressionInAggException(ExpressionCompiler.java:1141)
at org.apache.phoenix.compile.ProjectionCompiler.compile(ProjectionCompiler.java:378)
at org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:490)
at org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:447)
at org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:154)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:331)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:314)
at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:230)
at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:226)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:225)
at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1066)
at sqlline.Commands.execute(Commands.java:822)
at sqlline.Commands.sql(Commands.java:732)
at sqlline.SqlLine.dispatch(SqlLine.java:808)
at sqlline.SqlLine.begin(SqlLine.java:681)
at sqlline.SqlLine.start(SqlLine.java:398)
at sqlline.SqlLine.main(SqlLine.java:292