In article <[EMAIL PROTECTED]>, Tarlika Elisabeth Schmitz <[EMAIL PROTECTED]> 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 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql