Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 197BB632B3B for ; Fri, 2 Oct 2009 02:33:25 -0300 (ADT) 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 05064-09 for ; Fri, 2 Oct 2009 05:33:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-vw0-f193.google.com (mail-vw0-f193.google.com [209.85.212.193]) by mail.postgresql.org (Postfix) with ESMTP id 6761B6323C0 for ; Fri, 2 Oct 2009 02:33:17 -0300 (ADT) Received: by vws31 with SMTP id 31so483767vws.19 for ; Thu, 01 Oct 2009 22:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=E7sHM2ctcfYKHAm6YCd4ubH3IH9lPTkZ2Nqx0fy5Pbc=; b=f3FYbrCsiosAlTILcN5V933AKYouOsp81Y9hyV267osAoUGwdTbmveeYXvV94inVmE qrcEHdeHmb83MjZnlNgFRIFZOlonyZFZm4DOwKWWYVdyjotu9HKc9TlHJOTWllLIaFmE yLNqtAZvU9FTIv8Ljsix2iUulTrB7hQfbetOs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=j42OnmpKxToyXwA+jDfczXxT1mPMxKQ3A+t2CcL8+Aiy5r1Zp/2o5WdciiBBDU/1ci h6StMxFf+hp1rBvC+t0oODD1iDYB1XdWOAamsxWn9cGdD7qKbWgX9Ntev8UFhTYRvoXB utNuMGrilgjIeG+8+mlPgiAwQKTyw63dlEGqs= MIME-Version: 1.0 Received: by 10.220.17.37 with SMTP id q37mr3743164vca.111.1254461596334; Thu, 01 Oct 2009 22:33:16 -0700 (PDT) Date: Fri, 2 Oct 2009 15:33:16 +1000 X-Google-Sender-Auth: cd271d9d609ebb2a Message-ID: Subject: right join problem From: Greenhorn To: pgsql-sql@postgresql.org Content-Type: text/plain; charset=UTF-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.74 tagged_above=-10 required=5 tests=BAYES_20=-0.74 X-Spam-Level: X-Archive-Number: 200910/10 X-Sequence-Number: 33209 Hi, I'm trying to retrieve all meter_id from table meter, and for meter_id without amount, I'd like it to show nothing, 'null'. I've used right join here but it's not giving me my desired result. Is there another way to do this? Here's the query I'm trying. Thanks in advance! select m.meter_id, mp.meter_id, sum(amount_in_cents) as am from meter m right join transaction_mpark mp on (m.meter_id = mp.meter_id) where date_time between '2009-09-28 00:00:00' and '2009-10-04 23:59:59' group by m.meter_id, mp.meter_id order by m.meter_id