如何按月计算行数(How to count rows month wise)

编程入门 行业动态 更新时间:2024-10-26 19:35:12
如何按月计算行数(How to count rows month wise)

有了这个查询,我可以数数

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

With this query i can count

Created By ProductGroup Count HNSHAK MOBILE COMPUTING 13 HNSHAK STORAGE 2

Query:

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

now i want to count same month wise like MARCH/APRIL or 04-2013/03-2013 kindly help if it is possible i have a database in which more than 15000 entries i want to show each user count month wise...

i want output like this

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

table:

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])

MonthName

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

更多推荐

本文发布于:2023-08-07 00:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1458945.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按月   行数   count   wise   month

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!