Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 433E59FC46F for ; Tue, 5 Jun 2007 09:18:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 74175-04 for ; Tue, 5 Jun 2007 09:18:15 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.247]) by postgresql.org (Postfix) with ESMTP id 229AC9FC13D for ; Tue, 5 Jun 2007 09:18:20 -0300 (ADT) Received: by an-out-0708.google.com with SMTP id c36so389785ana for ; Tue, 05 Jun 2007 05:18:19 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=HM4TxsaHgpB5F+Z58nNi9rVteJNdu2Zo6jOx+KzrMSKYT+IAGWimZSt5hWuHJs6OjpYVVn00a8w4jri1s9ppr0lllYubaqIJqIRy4B5tBf9cVG5hComzCrme1yulpvjZb/pQLIxHOMGAVojeevpqJx01IoUD+yL2rJ9/pipomuY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=ZFKyyQt+Proq01hf1v5skXUPthWkLHOKaSINTthAdz7yw7yWTxShy7qQML1U/AIYIZcT/tisYzD4ZsDNR5/tivw6ex7/73zHYQL20jtL/WCtW7Y5dOV/30bRLjcwjjXnK4xcnn79u27G3N50Jd1G6A+tZp45XpcEM+F23u8j2k8= Received: by 10.100.95.19 with SMTP id s19mr3178739anb.1181045898648; Tue, 05 Jun 2007 05:18:18 -0700 (PDT) Received: by 10.100.42.1 with HTTP; Tue, 5 Jun 2007 05:18:18 -0700 (PDT) Message-ID: <1c23c8e70706050518v19c56d21j873985125b930db@mail.gmail.com> Date: Tue, 5 Jun 2007 15:18:18 +0300 From: "Loredana Curugiu" To: "Richard Huxton" , pgsql-novice@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] JOIN In-Reply-To: <4665537A.2060601@archonet.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_10239_27859022.1181045898613" References: <1c23c8e70706050111i5ba672d6j78bd9afa4b786616@mail.gmail.com> <1c23c8e70706050426y12d567ban70ffdafb75808e0e@mail.gmail.com> <4665537A.2060601@archonet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/26 X-Sequence-Number: 18924 ------=_Part_10239_27859022.1181045898613 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline >> 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? I am trying to say that sum column it is not calculated correctly. 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. Yes, I am working with timestamp with time zone . Regards, Loredana ------=_Part_10239_27859022.1181045898613 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
>> 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?

I am trying to say that sum column it is not calculated correctly.  

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.

Yes, I am working with timestamp with time zone .


Regards,
        Loredana

------=_Part_10239_27859022.1181045898613--