From: Richard Huxton <dev@archonet.com>
To: Loredana Curugiu <loredana.curugiu@gmail.com>
Cc: pgsql-novice@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: Re: JOIN
Date: Tue, 05 Jun 2007 13:39:29 +0100
Message-ID: <46655981.4050403@archonet.com> (raw)
In-Reply-To: <1c23c8e70706050518v19c56d21j873985125b930db@mail.gmail.com>
References: <1c23c8e70706050111i5ba672d6j78bd9afa4b786616@mail.gmail.com>
<1c23c8e70706050426y12d567ban70ffdafb75808e0e@mail.gmail.com>
<4665537A.2060601@archonet.com>
<1c23c8e70706050518v19c56d21j873985125b930db@mail.gmail.com>
Loredana Curugiu wrote:
>>> 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.
But you're not saying what you think the figure(s) should be.
There's two possibilities:
1. SUM() has a bug and can't add up numbers. Unlikely
2. The INNER JOIN isn't working as you think it should. This seems more
likely.
Try the query without totalling, just to see what matches you're getting.
> 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 .
You're happy that daylight-saving adjustments aren't causing any
problems with your timezone settings then?
--
Richard Huxton
Archonet Ltd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, loredana.curugiu@gmail.com, pgsql-novice@postgresql.org
Subject: Re: JOIN
In-Reply-To: <46655981.4050403@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox