postgresql - Sum sql data where LOOP -


i have table

 s_hostid |   s_name   |    s_size ----------+------------+--------------         5 | 2014-01-09 |   1082705867         5 | 2014-01-08 |   1082713736         5 | 2014-01-04 |   1082686097         5 | 2014-01-03 |   1082677818         5 | 2014-01-06 |   1082701853        10 | 2014-01-06 |      7536036        10 | 2014-01-02 |      7536032        10 | 2014-01-08 |      7536036        10 | 2014-01-01 |      7536020        10 | 2014-01-05 |      7536036        10 | 2014-01-03 |      7536032        10 | 2014-01-09 |      7536032        50 | 2014-01-03 |  11416224886        11 | 2014-01-01 |           39        11 | 2014-01-06 |           39        11 | 2014-01-07 |           39        11 | 2014-01-09 |           39        36 | 2014-01-02 |     22164534 

how can sum values s_size field per value s_name? tried this

"select s_name,(select sum(s_size) storage s_name = (select distinct s_name storage)) storage" 

but have error:

error:  more 1 row returned subquery used expression 

thanks responses.

this group by clause - breaks down query groups, , applies aggregate function per each group. in case:

select   s_name, sum(s_size)     my_table group s_name 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -