Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 45AF49FBF22; Tue, 5 Jun 2007 09:13:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 73501-09; Tue, 5 Jun 2007 09:13:43 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id C99C69FBF96; Tue, 5 Jun 2007 09:13:48 -0300 (ADT) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 3539277067; Tue, 5 Jun 2007 13:13:47 +0100 (BST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 48329410CE4; Tue, 5 Jun 2007 13:14:38 +0100 (BST) Message-ID: <4665537A.2060601@archonet.com> Date: Tue, 05 Jun 2007 13:13:46 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: Loredana Curugiu Cc: pgsql-novice@postgresql.org, pgsql-sql@postgresql.org Subject: Re: JOIN References: <1c23c8e70706050111i5ba672d6j78bd9afa4b786616@mail.gmail.com> <1c23c8e70706050426y12d567ban70ffdafb75808e0e@mail.gmail.com> In-Reply-To: <1c23c8e70706050426y12d567ban70ffdafb75808e0e@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/26 X-Sequence-Number: 28516 Loredana Curugiu wrote: > Any help, please? >> So I have the following query: >> >> SELECT SUM(A.count), >> A.theme, >> A.receiver, >> A.dates >> FROM my_table A >> INNER JOIN my_table B >> ON A.theme=B.theme >> AND A.receiver=B.receiver >> AND A.date=ANY(B.dates) >> GROUP BY A.theme,A.receiver, A.dates; [snip] >> >> The result is wrong. I don't know what it is wrong at my query. >> Please help. You don't actually say what's wrong. What are you expecting as output? Oh, and your "date" column isn't - it's a timestamp with time-zone. That might or might not cause confusion with daylight-saving-times. -- Richard Huxton Archonet Ltd