I tried a lot but can´t find the right way. If I select values in Postgres and sum them it looks like this:
SELECT name,sum(size) as total
FROM mytable group by name order by name;
How can I alter this so it also sum all values in total? I think I need a subselect but how?
Try this:
UPDATE I'm sorry, I don't read that you want it all in the same query. For this reason the answer of greg it's better. However, other possibility if you have a postgresql version >= 9:
I would use the ROLLUP function on POSTRGESQL:
This will give you a grand total of any value that you aggregate and can also be used for aggregating multiple columns.
Hope it helps!
Well this should help you:
If you want all results with the same SELECT, you could do something like
Hope it helps…