Search code examples
mysqlrollup

mysql select * from table group by id with rollup


I try to select from my table and rollup to get the Total but i failed. Here is my table and values enter image description here

and the result i want like this

enter image description here

is this possible? my query :

select * from mytable group by id with rollup;

But my query failed to get the rollup values, please show me the way thanks


Solution

  • try this:

    select id,sum(qty),sum(import),sum(loss),sum(results) 
    from mytable group by id asc with rollup;