Oops I tested this and didn't get what you wanted. try this instead.
>
> This is untested. Also I am not sure that this is what you want, but I do not know how you
> arrive
> at the values in your summary table.
>
> select
> distinct on (titolo)
^^^^^^
> 'any' as cod_rif,
> titolo,
> sum(quantity),
> cmf,
> u_qq,
> mont,
> vend,
> from
> test_t
> group by
> titolo,
> cmf,
> u_qq,
> mont,
> vend
> ;
Regards,
Richard Broersma Jr.