Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to count rows month wise

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
like image 379
H4SN Avatar asked Jan 18 '26 21:01

H4SN


1 Answers

MonthName

select [created by],
       ProductGroup,
       Count(Productgroup),
       MonthName([Initial Intl Created])
from tablename
group by [created by],ProductGroup,MonthName([Initial Intl Created])
like image 119
Prahalad Gaggar Avatar answered Jan 20 '26 15:01

Prahalad Gaggar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!