| From: | Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: exclude part of result |
| Date: | 2008-06-27 09:33:07 |
| Message-ID: | pubq1nfcj0.fsf@srv.protecting.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
In article <20080627075136(dot)12add021(at)dick(dot)coachhouse>,
Tarlika Elisabeth Schmitz <postgresql(at)numerixtechnology(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Marc Mamin | 2008-06-27 10:50:03 | Re: exclude part of result |
| Previous Message | Tarlika Elisabeth Schmitz | 2008-06-27 06:51:36 | Re: exclude part of result |