Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 1D508632563 for ; Fri, 12 Feb 2010 18:33:03 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 34882-01 for ; Fri, 12 Feb 2010 22:32:51 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sargon.lncsa.com (mail.lncsa.com [213.215.28.11]) by mail.postgresql.org (Postfix) with ESMTP id A173C63230C for ; Fri, 12 Feb 2010 18:32:51 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by sargon.lncsa.com (Postfix) with ESMTP id C9963301E6E9 for ; Fri, 12 Feb 2010 23:32:49 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lncsa.com Received: from sargon.lncsa.com ([127.0.0.1]) by localhost (sargon.lncsa.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JxelUYKpEHkd for ; Fri, 12 Feb 2010 23:32:49 +0100 (CET) Received: from zenon.apartia.fr (zenon.apartia.fr [10.0.3.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "zenon.apartia.fr", Issuer "ca.apartia.fr" (verified OK)) by sargon.lncsa.com (Postfix) with ESMTP id AA79F301E6DD for ; Fri, 12 Feb 2010 23:32:49 +0100 (CET) Received: from delos.apartia.fr (delos.apartia.fr [10.0.3.107]) by zenon.apartia.fr (Postfix) with ESMTP id 1F070589B2CAF for ; Fri, 12 Feb 2010 23:32:49 +0100 (CET) Received: by delos.apartia.fr (Postfix, from userid 1000) id 1B7BF200F1094; Fri, 12 Feb 2010 23:32:49 +0100 (CET) Date: Fri, 12 Feb 2010 23:32:49 +0100 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: complex join question Message-ID: <20100212223248.GA29691@apartia.fr> Mail-Followup-To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/48 X-Sequence-Number: 33647 Hi, Here is my schema: cruise_line -> ship(id_line) -> cruise_type(id_ship) -> cruise(id_cruise_type) -> price(id_cruise, id_currency) <- currency (USD,GBP,EUR,CAD) (a 'cruise' is a 'cruise_type' + a date) I am trying to display a count of cruise's for each ship and each currency even if that count is 0. But I am having trouble building the query, as some 'cruise's might not (yet) have a 'price' in all currencies and so no link to 'currency'. Thanks,