Re: selecting rows based on unique fields in a column

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: John Siggins <j-siggins(at)blueyonder(dot)co(dot)uk>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: selecting rows based on unique fields in a column
Date: 2003-11-05 14:02:18
Message-ID: ef0iqvcepq0durqp8e7vb8jqj726dubgok@email.aon.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wed, 05 Nov 2003 11:52:30 +0000, John Siggins
<j-siggins(at)blueyonder(dot)co(dot)uk> wrote:
> select reqitem from lasting
>group by reqitem having count(reqitem) = 1;
>
>But this gives me only reqitem column and I want the rest of the row!

SELECT l.*
FROM lasting AS l INNER JOIN (
SELECT reqitem FROM lasting
GROUP BY reqitem HAVING count(reqitem) = 1
) AS x ON l.reqitem = x.requitem;

Servus
Manfred

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Damon 2003-11-05 14:29:45 Re: How to know column constraints via system catalog tables
Previous Message John Siggins 2003-11-05 11:52:30 selecting rows based on unique fields in a column