gpt4 book ai didi

mysql - 如何按月计算行数

转载 作者:可可西里 更新时间:2023-11-01 08:50:02 25 4
gpt4 key购买 nike

通过这个查询我可以数数

Created By  ProductGroup           Count
HNSHAK MOBILE COMPUTING 13
HNSHAK STORAGE 2

查询:

SELECT `Created By`, ProductGroup, COUNT(*) `Count`
FROM tablename
GROUP BY `Created By`, ProductGroup;

现在我想像 MARCH/APRIL 或 04-2013/03-2013 一样计算同月,如果可能的话请帮助我有一个数据库,其中超过 15000 个条目我想显示每个用户月数.. .

我想要这样的输出

Created By  ProductGroup           Count    MONTH
HNSHAK MOBILE COMPUTING 1 MARCH
HNSHAK STORAGE 2 MARCH


Created By ProductGroup Count MONTH
HNSHAK MOBILE COMPUTING 2 APRIL
HNSHAK STORAGE 1 APRIL

Created By ProductGroup Count MONTH
HNSHAK MOBILE COMPUTING 1 FEBRUARY

表格:

Productgroup    Created By  Initial Intl Created
STORAGE HNSHAK 13.02.2013
SMART+MOBIL+FIX PH. KFKAIS 19.03.2013
SMART+MOBIL+FIX PH. KFKAIS 20.03.2013
SMART+MOBIL+FIX PH. KFKAIS 19.03.2013
SCANNERS MDSALA 20.02.2013
STORAGE HNSHAK 07.03.2013
STORAGE HNSHAK 13.03.2013
MOBILE COMPUTING HNSHAK 01.03.2013
MOBILE COMPUTING HNSHAK 01.04.2013
MOBILE COMPUTING HNSHAK 01.04.2013
PTV/FLAT WSAHMA 12.03.2013
PTV/FLAT WSAHMA 09.03.2013
STORAGE HNSHAK 13.03.2013

最佳答案

MonthName

select [created by],
ProductGroup,
Count(Productgroup),
MonthName([Initial Intl Created])
from tablename
group by [created by],ProductGroup,MonthName([Initial Intl Created])

关于mysql - 如何按月计算行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16008462/

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