Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id B493E2E0061 for ; Tue, 19 Feb 2008 09:51:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 66501-04-6 for ; Tue, 19 Feb 2008 09:51:24 -0400 (AST) Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by postgresql.org (Postfix) with ESMTP id CEE1F2E0044 for ; Tue, 19 Feb 2008 09:51:12 -0400 (AST) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by ptb-relay03.plus.net with esmtp (Exim) id 1JRSsI-0004ib-Jf; Tue, 19 Feb 2008 13:51:10 +0000 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 6F7C6274059; Tue, 19 Feb 2008 13:51:10 +0000 (GMT) Message-ID: <47BADECE.7050603@archonet.com> Date: Tue, 19 Feb 2008 13:51:10 +0000 From: Richard Huxton User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: Shavonne Marietta Wijesinghe CC: pgsql-sql@postgresql.org Subject: Re: SELECT DISTINCT References: <00c001c872de$5a7dd000$3102a8c0@dream> In-Reply-To: <00c001c872de$5a7dd000$3102a8c0@dream> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Plusnet-Relay: 8341a4e268f5ecfece39ef36dea473f2 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/151 X-Sequence-Number: 30242 Shavonne Marietta Wijesinghe wrote: > Hello > > I have 2 records with the same value. Even when i do a select with > DISTINCT, it returns me both the records instead of one. > > SELECT DISTINCT ON (TE_COGNOME) TE_COGNOME, TE_NOME, N_GEN_TEST, > TE_SESSO, TE_ATTNASC, TE_LUONASC, TE_INDI, TE_DTNASC, TE_PROVSTATO, > TE_PROV, TE_PATERNITA, TE_RICHIESTA FROM MOD48_02 WHERE TE_COGNOME > LIKE 'WIJ%' AND TRIM(DELETED) IS NULL ORDER BY TE_COGNOME, N_GEN_TEST > DESC; Can you provide: 1. The output of your query (just the duplicate rows will be fine) 2. The output of "\d MOD48_02"? 3. The output of: SELECT xmin,xmax, ':' || TE_COGNOME || ':' FROM MOD48_02 WHERE TE_COGNOME = ??? For the duplicate value of course -- Richard Huxton Archonet Ltd