在SQL中使用分组依据功能时遇到问题

护身符

为什么mySQL函数返回not a single group function error

SELECT order#, TO_CHAR(quantity*paideach, '$999.99') AS "Order Total"
FROM orderitems
GROUP BY order#;
蒂姆·比格莱森(Tim Biegeleisen)

您是要对已付金额进行总计吗?试试这个版本:

SELECT order#, TO_CHAR(SUM(quantity*paideach), '$999.99') AS "Order Total"
FROM orderitems
GROUP BY order#;

您看到此错误是因为您已指示Oracle通过来聚合orderitemsorder#这意味着它将报告给定订单的所有记录的汇总,因此选择quantity*paideach,这是单个记录的属性没有意义求和应该可以解决此错误。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章