【已解决】doris 的 group by

Viewed 38

select record_id, seller_id from sales_records group by record_id
提示 Execution failed: Error Failed to execute sql: java.sql.SQLException: (conn=19) errCode = 2, detailMessage = select list expression not produced by aggregation output (missing from GROUP BY clause?): seller_id
这个如何增加相对应的配置

1 Answers

目前doris的SQL语法还是比较严格的语法,不支持这样省略的写法

select record_id, seller_id from sales_records group by record_id

这种SQL,要么在前面把非group by的字段加上聚合函数,如下:

select record_id, max(seller_id) from sales_records group by record_id

要么得补全group by的字段,如下:

select record_id, seller_id from sales_records group by record_id,seller_id