gpt4 book ai didi

Mysql 一张表中有多个订单行

转载 作者:行者123 更新时间:2023-11-29 00:01:16 26 4
gpt4 key购买 nike

我想按升序排列前一年的行,按降序排列当年的行。这是我的查询:

SELECT WEEKOFYEAR(DATE) AS WEEK,
YEAR(DATE) YEAR,
COUNT(id) WeekAvg
FROM `user_appoint`
WHERE user_appoint.comp_id=123
GROUP BY WEEK(DATE) , YEAR(DATE)
ORDER BY YEAR(DATE) ASC;

输出是:

week    Year  WeekAvg  
------ ------ ---------
46 2014 3
47 2014 1
48 2014 6
52 2014 1
12 2015 1
11 2015 1
5 2015 1

但我的预期输出是:

week    Year  WeekAvg  
------ ------ ---------
46 2014 3
47 2014 1
48 2014 6
52 2014 1
5 2015 1
11 2015 1
12 2015 1

最佳答案

尝试一下

SELECT WEEKOFYEAR(DATE) AS WEEK,
YEAR(DATE) YEAR,
COUNT(id) WeekAvg
FROM `user_appoint`
WHERE user_appoint.comp_id=123
GROUP BY WEEK(DATE) , YEAR(DATE)
ORDER BY YEAR(DATE) ASC, WEEKOFYEAR(DATE) ASC;

关于Mysql 一张表中有多个订单行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29692445/

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