Skip site navigation (1) Skip section navigation (2)

Re: exclude part of result

From: "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de>
To: "Harald Fuchs" <hari(dot)fuchs(at)gmail(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: exclude part of result
Date: 2008-06-27 10:50:03
Message-ID: CA896D7906BF224F8A6D74A1B7E54AB3039E8A54@JENMAIL01.ad.intershop.net (view raw or flat)
Thread:
Lists: pgsql-sql
Hi,

Two other ideas...

SELECT DISTINCT p.a, p.b, p.c, now(), count(item.item_pk) 
FROM product p 
     JOIN
     (select distinct a,b,c from  products
      except
      select distinct a,b,c from  navigation
     )foo  
     USING (a,b,c)
     LEFT JOIN item ON item.product_fk = product_pk
WHERE ...
GROUP BY p.a, p.b, p.c


or maybe 

SELECT DISTINCT foo.*, now(), count(item.item_pk) 
FROM (select distinct a,b,c from  products
      WHERE ...
      except
      select distinct a,b,c from  navigation
     )foo  
     LEFT JOIN item ON item.product_fk = product_pk
WHERE ...
GROUP BY p.a, p.b, p.c

HTH,

Marc Mamin

In response to

pgsql-sql by date

Next:From: Tarlika Elisabeth SchmitzDate: 2008-06-27 11:22:38
Subject: Re: exclude part of result
Previous:From: Harald FuchsDate: 2008-06-27 09:33:07
Subject: Re: exclude part of result

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group