I mean: I want to select the records wich for co1,n1,l1,m1 value are the same and has the maxim value of the ore field adding to that value the value of the records which are not selected.
SELECT co,clo1,nl,l1,m1,SUM(ore) AS tot_ore FROM xxx WHERE <conditions here> GROUP BY co,clo1,nl,l1,m1 ORDER BY co,clo1,nl,l1,m1;
-- Richard Huxton Archonet Ltd
---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html