Re: exclude part of result - Mailing list pgsql-sql

From Harald Fuchs
Subject Re: exclude part of result
Date
Msg-id pubq1nfcj0.fsf@srv.protecting.net
Whole thread Raw
In response to Re: exclude part of result  (Tarlika Elisabeth Schmitz <postgresql@numerixtechnology.de>)
Responses Re: exclude part of result  ("Marc Mamin" <M.Mamin@intershop.de>)
Re: exclude part of result  (Tarlika Elisabeth Schmitz <postgresql@numerixtechnology.de>)
List pgsql-sql
In article <20080627075136.12add021@dick.coachhouse>,
Tarlika Elisabeth Schmitz <postgresql@numerixtechnology.de> writes:

> PRODUCT table :

> A B C
> 100 200 300
> 100 200 301
> 100 205 300
> 100 205 301

> NAVIGATION table
> A B C #ITEMS
> 100 200 300 5
> 100 200 301 6

> My query needs to return 
> 100 205 300 #items
> 100 205 301 #items
> so I can insert them in NAVIGATION. NAVIGATION must not contain any
> duplicate combinations of [a,b,c].

Just use another LEFT JOIN to filter out the corresponding product lines:

SELECT DISTINCT a, b, c, now(), count(item_pk) 
FROM product
LEFT JOIN navigation USING (a, b, c)
LEFT JOIN item ON item.product_fk = product_pk
WHERE navigation.a IS NULL
GROUP BY a, b, c



pgsql-sql by date:

Previous
From: Tarlika Elisabeth Schmitz
Date:
Subject: Re: exclude part of result
Next
From: "Marc Mamin"
Date:
Subject: Re: exclude part of result