Em 13 de abril de 2011 14:46, Fabiano Fernandes <
[email protected]> escreveu:

>
> Como fazer para que seja retornado o valor que preciso?
>
> id  | nota
> ----+-------
>   1 |   9.5
>
>
>
Veja se resolve:

postgres@bdteste=# create table notas(id integer, nota numeric);
CREATE TABLE
postgres@bdteste=# insert into notas values (1, 4.5), (1, 5.0), (1, 4.5),
(1, 5.0);
INSERT 0 4
postgres@bdteste=# select id, sum(distinct nota) from notas group by id;
 id | sum
----+-----
  1 | 9.5
(1 row)


Cordialmente,
-- 
Fabrízio de Royes Mello
>> Blog sobre TI: http://fabriziomello.blogspot.com
>> Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a