Re: Distinct oddity

From: Rob Sargent <robsargent(at)rocketmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Distinct oddity
Date: 2009-05-08 14:55:35
Message-ID: 398183.56536.qm@web59506.mail.ac4.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Is firmen a table or a view?

________________________________
From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Maximilian Tyrtania <maximilian(dot)tyrtania(at)onlinehome(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Sent: Friday, May 8, 2009 5:35:21 AM
Subject: Re: [SQL] Distinct oddity

On Fri, May 8, 2009 at 3:28 AM, Maximilian Tyrtania
<maximilian(dot)tyrtania(at)onlinehome(dot)de> wrote:
> am 07.05.2009 20:54 Uhr schrieb Scott Marlowe unter scott(dot)marlowe(at)gmail(dot)com:
>
>> On Thu, May 7, 2009 at 2:21 AM, Maximilian Tyrtania
>> <maximilian(dot)tyrtania(at)onlinehome(dot)de> wrote:
>>> Hi there,
>>>
>>> does this look right?
>>>
>>> FAKDB=# select count(distinct(f.land)) from firmen f where
>>> f.typlist='Redaktion';
>>> count
>>> -------
>>> 1975
>>> (1 row)
>>>
>>> FAKDB=# select count(distinct(f.land||'1')) from firmen f where
>>> f.typlist='Redaktion';
>>> count
>>> -------
>>> 4944
>>> (1 row)
>>
>> Yeah, that does seem odd. Could it be something like nulls in your
>> data set? just guessing really. If you could make a small test case
>> that shows it happening and allows others to reproduce it you're
>> likely to get more bites.
>
> It doesn't seem to be related to null values (which wouldn't explain it
> anyway) nor to this particular field...
>
> FAKDB=# select count(*) from firmen where bezeichnung is null;
> count
> -------
> 0
> (1 row)

That's not the same field as in the original query.

> My attempts at reproducing this with a freshly created table failed, of
> course.

Instead of trying to create a test case from scratch, isolate some
rows that cause this, put them in another table, and then pg_dump that
one table, cleaned as needed for privacy, here.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Oliveiros Cristina 2009-05-08 15:36:34 performance question
Previous Message Gerardo Herzig 2009-05-08 13:40:17 Re: RAISE NOTICE