Re: Unexpected results when joining on date fields

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: Tim Uckun <tim(at)basediary(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Unexpected results when joining on date fields
Date: 2011-07-12 17:06:10
Message-ID: 980063D6-C221-4083-BB45-3B5DC55E364A@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11 Jul 2011, at 1:58, Tim Uckun wrote:

> I have two tables, traffic and sales. Each one has a date field and
> lists the traffic and sales broken down by various parameters
> (multiple rows for each date).
>
> If I run select (select count(*) from traffic) as traffic, (select
> count(*) from sales) as sales; I get the following 49383;167807
>
> if I run select count(*) from traffic t inner join sales s on t.date
> = s.date I get 24836841.

Perhaps you also want to filter that join so that you don't get matches for different articles sold at the same date? Just joining on date doesn't seem to make a whole lot of sense.

Alban Hertroys

--
The size of a problem often equals the size of an ego.

!DSPAM:737,4e1c7f0c12096580658153!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shianmiin 2011-07-12 17:10:50 Re: plpgsql function confusing behaviour
Previous Message Tony Wang 2011-07-12 16:52:40 Weird problem that enormous locks