Reputation: 73
I try to select from my table and rollup to get the Total but i failed. Here is my table and values
and the result i want like this
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
Upvotes: 0
Views: 470
Reputation: 2159
You can do something like below
select coalesce(CAST(id as CHAR(50)),'Total'),
max(local),sum(import),sum(loss),sum(results) from mytable group by id asc with rollup
Upvotes: 1
Reputation: 4211
try this:
select id,sum(qty),sum(import),sum(loss),sum(results)
from mytable group by id asc with rollup;
Upvotes: 3