X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9457BD1B520 for ; Thu, 23 Oct 2003 18:48:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 06740-09 for ; Thu, 23 Oct 2003 15:47:34 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 771AAD1B522 for ; Thu, 23 Oct 2003 15:47:32 -0300 (ADT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id h9NIjsDd024535; Thu, 23 Oct 2003 12:45:55 -0600 (MDT) Date: Thu, 23 Oct 2003 12:34:13 -0600 (MDT) From: "scott.marlowe" To: Cc: Subject: Re: Query Help In-Reply-To: <7E2F242E.303998B7.037EC703@netscape.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/312 X-Sequence-Number: 15712 On Thu, 23 Oct 2003 yusuf0478@netscape.net wrote: > I'm interested in finding the minimim A.id such that the following holds: > > select A.charge > , B.user_id > , C.employee_id > from A > inner join B using (user_id) > inner join C using (employee_id) > > except > > select X.charge > , Y.user_id > , Z.employee_id > from X > inner join Y using (user_id) > inner join Z using (employee_id) > > -- > > I can't do the following, since the number of selected columns have to match: > > select A.id > , A.charge > , B.user_id > , C.employee_id > from A > inner join B using (user_id) > inner join C using (employee_id) > > except > > select X.charge > , Y.user_id > , Z.employee_id > from X > inner join Y using (user_id) > inner join Z using (employee_id) Maybe you can add a dummy field in the second half like this: except select -1 , X.charge , Y.user_id , Z.employee_id ???