gpt4 book ai didi

mysql - MySQL 是否像 oracle 一样支持部分汇总?

转载 作者:行者123 更新时间:2023-11-29 02:50:38 25 4
gpt4 key购买 nike

正如 oracle 文档所说,它支持部分汇总:

Partial RollupYou can also roll up so that only some of the sub-totals will be included. This partial rollup uses the following syntax:

GROUP BY expr1, ROLLUP(expr2, expr3);

In this case, the GROUP BY clause creates subtotals at (2+1=3) aggregation levels. That is, at level (expr1, expr2, expr3), (expr1, expr2), and (expr1).

http://docs.oracle.com/cd/E11882_01/server.112/e25554/aggreg.htm#DWHSG8612

MySQL 支持吗?

我试图在 MySQL 文档中搜索,但找不到任何线索。

最佳答案

关于 with rollup clause 的 Mysql 文档非常清楚:您不能向汇总子句提供列列表来指示您希望执行汇总的级别。

您可以做的是在子查询中使用 rollup 子句进行查询,在外部查询中您可以删除不需要的聚合行(或者您可以在客户端应用程序中执行此操作)。你不能在 having 子句中这样做,因为

Because the NULL values in the super-aggregate rows are placed into the result set at such a late stage in query processing, you cannot test them as NULL values within the query itself. For example, you cannot add HAVING product IS NULL to the query to eliminate from the output all but the super-aggregate rows.

On the other hand, the NULL values do appear as NULL on the client side and can be tested as such using any MySQL client programming interface.

关于mysql - MySQL 是否像 oracle 一样支持部分汇总?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36450964/

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