Link to home
Get AccessLog in
Avatar of HemlockPrinters
HemlockPrinters

asked on

MySQL query to get group total using Group by With ROLLUP?

Please help me with MySQL query, thanks.

Here is my sample table:

ID  Service Quantity
3          a             3
1          a             2
12        c           22
5          c           6
10        c            3
20        b            1
11        b            1
4          b            2


I would like to get the subtotal and total, the data is grouped by and sorted by service, also in each group, ID is sorted,  the result is as belowt:
ID Service Quantity
1        a         2
3        a         3
Subtotal :    5
            
4       b         2
11     b         1
20     b         1
Subtotal:    4
            
5       c        6
10     c        3
12     c      22
Subtotal:   31  

Total:         40
ASKER CERTIFIED SOLUTION
Avatar of Chris Luttrell
Chris Luttrell
Flag of United States of America image

Link to home
membership
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access