Postgres: select the sum of values and then sum this again

后端 未结 4 1714
太阳男子
太阳男子 2020-12-24 09:14

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         


        
4条回答
  •  不知归路
    2020-12-24 09:46

    Well this should help you:

    select sum(innerselect.innertotal) as outertotal from 
        (select sum(size) as innertotal from mytable group by name) as innerselect
    

提交回复
热议问题