Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6D78098E59C for ; Tue, 8 Nov 2011 11:03:28 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 17091-08 for ; Tue, 8 Nov 2011 15:03:22 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mmmail1.mcr.colo.comodoca.net (mdfw.comodoca.net [91.209.196.68]) by mail.postgresql.org (Postfix) with ESMTP id ED96F98E58B for ; Tue, 8 Nov 2011 11:03:21 -0400 (AST) Received: (qmail 15599 invoked from network); 8 Nov 2011 15:03:19 -0000 Received: from ian.bd.office.comodo.net (HELO ian.brad.office.comodo.net) (192.168.0.201) by mail.colo.comodoca.net with ESMTPS (DHE-RSA-AES256-SHA encrypted); 8 Nov 2011 15:03:19 -0000 Received: (qmail 10625 invoked by uid 1000); 8 Nov 2011 15:03:19 -0000 Received: from Unknown (HELO [192.168.199.58]) (192.168.199.58) (smtp-auth username robinst, mechanism plain) by ian.brad.office.comodo.net (qpsmtpd/0.40) with (CAMELLIA256-SHA encrypted) ESMTPSA; Tue, 08 Nov 2011 15:03:19 +0000 Message-ID: <4EB944B6.7030905@comodo.com> Date: Tue, 08 Nov 2011 20:33:18 +0530 From: Robins Tharakan Organization: Comodo User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15 MIME-Version: 1.0 To: pgsql-sql@postgresql.org CC: Tarlika Elisabeth Schmitz Subject: Re: GROUP and ORDER BY References: <20111107212031.4d6310aa@dick.coachhouse> <4EB8AF9C.7060305@comodo.com> <20111108095958.2b6f3ad9@dick.coachhouse> In-Reply-To: <20111108095958.2b6f3ad9@dick.coachhouse> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201111/35 X-Sequence-Number: 36008 Hmmm... Missed that! I think you are looking for the feature that was introduced in PostgreSQL 9.1 where you could have a non-group-by column in the select list, but only if the group-by has a pkey to identify the actual row. http://www.postgresql.org/docs/9.1/static/release-9-1.html (Search for GROUP BY) -- Robins Tharakan On 11/08/2011 03:29 PM, Tarlika Elisabeth Schmitz wrote: > Thank you for yuor suggestion, Robins. Unfortunately, it does not work; > this returns: > 1787 "Toomyvara" 0.5 > 1787 "Toomevara" 0.4 > 1188 "Toonybara" 0.4 > because while column "no" is identical, "name" isn't and you're > grouping by both of them.