gpt4 book ai didi

mysql - "group by desc"在 MySQL 中有什么作用?

转载 作者:行者123 更新时间:2023-11-29 03:59:26 25 4
gpt4 key购买 nike

我偶然注意到这似乎不是我预期的语法错误

select `InvoiceNumber`, `_Total`, date(`__Added`)`Date` 
from `orders`
where`__Added`>=curdate()-interval 7 day
group by `Date`desc
order by `Date`;

删除它似乎并没有改变我的结果,并且 desc 没有出现在 group by https://dev.mysql.com/doc/refman/8.0/en/group-by-handling.html 的文档页面上的任何地方。

它只是被解析器抛出了吗?或者使用 group by desc 真的有作用吗?

最佳答案

来自 docs

Prior to MySQL 8.0.13, MySQL supported a nonstandard syntax extension that permitted explicit ASC or DESC designators for GROUP BY columns.

它可能源于 MySQL GROUP BY 也暗示了排序;至少有一次,他们说不久前该功能已被弃用,但我不确定是否真的被删除了。

关于mysql - "group by desc"在 MySQL 中有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57366414/

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