## Re: How to obtain algebraic sum of equal lines

From: Oisin Glynn nasr(dot)laili(at)tin(dot)it, pgsql-novice(at)postgresql(dot)org Re: How to obtain algebraic sum of equal lines 2006-04-25 20:22:14 444E84F6.7090707@oisinglynn.com (view raw or flat) 2006-04-25 20:12:40 from Ennio-Sr  2006-04-25 20:22:14 from Oisin Glynn  2006-04-25 20:41:46 from Frank Bax   2006-04-25 21:21:22 from Ennio-Sr    2006-04-25 21:24:58 from Oisin Glynn     2006-04-25 21:53:38 from Ennio-Sr    2006-04-25 21:25:02 from Frank Bax     2006-04-25 22:00:59 from Ennio-Sr  2006-04-26 14:25:55 from Oscar Rodriguez Fonseca pgsql-novice
```Ennio-Sr wrote:
> Hi all,
> Is it possible, given the following table:
>
> cod_rif | titolo | quantity |   cmf   |  u_qq  |  mont   | vend |  sum
> ---------+--------+----------+---------+--------+---------+------+-------
>  26      | aaa    |    -1000 | 6.11098 |  6.176 |  6.1110 | t    | -1000
>  7       | aaa    |     2500 |  25.455 |      0 | 60.0897 | f    |  2500
>  28      | bbb    |     2700 |   3.862 |    4.6 |  4.1957 | f    |  2700
>  3       | bbb    |      500 |   6.057 | 10.129 | 18.7311 | f    |   500
>  34      | bbb    |     -700 |       0 |      0 |  0.0000 | t    |  -700
>  6       | bbb    |     -500 |   2.703 |  4.757 |  3.7151 | f    |  -500
>  30      | ccc    |     5000 |   1.717 |  1.489 |  1.7170 | f    |  5000
>  33      | ccc    |    10000 |    4.36 |      0 |  4.3600 | f    | 10000
>  11      | ddd    |    -1500 |  10.537 |  4.021 | 20.5815 | t    | -1500
>  32      | ddd    |     1500 | 0.55896 |  1.119 |  0.5590 | f    |  1500
> (10 rows)
>
> to get a selection whereby the algebraic sum of "quantity" for each equal 'titolo'
> is returned?
>
> I tried this query with no result:
> psql finanza -c "select * , (sum(quantity)) from  test_t group by cod_rif, titolo, quantity, cmf, u_qq, mont, vend order by titolo asc"
>
> Regards,
> 	Ennio.
>
>
>

Perhaps I am not seeing the light but would the following not give sum
per titolo?

select sum(quantity),titolo from test_t group by titolo;

Oisin

```

### pgsql-novice by date

 Next: From: Frank Bax Date: 2006-04-25 20:41:46 Subject: Re: How to obtain algebraic sum of equal lines Previous: From: Ennio-Sr Date: 2006-04-25 20:12:40 Subject: How to obtain algebraic sum of equal lines