pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
why these results?
5+ messages / 4 participants
[nested] [flat]

* why these results?
@ 2011-08-01 22:50 Wes James <comptekki@gmail.com>
  2011-08-01 23:00 ` Re: why these results? Adrian Klaver <adrian.klaver@gmail.com>
  2011-08-01 23:01 ` Re: why these results? Reinoud van Leeuwen <reinoud.v@n.leeuwen.net>
  2011-08-01 23:01 ` Re: why these results? Steve Crawford <scrawford@pinpointresearch.com>
  0 siblings, 3 replies; 5+ messages in thread

From: Wes James @ 2011-08-01 22:50 UTC (permalink / raw)
  To: pgsql-sql

select count(*) from table;

count
-------
   100
(1 row)


is correct

select count(*) from table where col::text ~~* '%text%';

count
-------
     1
(1 row)

is correct.

But now if I do:


select count(*) from table where col::text !~~* '%text%';
count
-------
  98
(1 row)

Shouldn't it be 99?  That is out of 100 records there is one that has
"text" in column "col" so the !~~* should return 99 rows.  ??

-wes



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: why these results?
  2011-08-01 22:50 why these results? Wes James <comptekki@gmail.com>
@ 2011-08-01 23:00 ` Adrian Klaver <adrian.klaver@gmail.com>
  2 siblings, 0 replies; 5+ messages in thread

From: Adrian Klaver @ 2011-08-01 23:00 UTC (permalink / raw)
  To: pgsql-sql; +Cc: Wes James <comptekki@gmail.com>

On Monday, August 01, 2011 3:50:00 pm Wes James wrote:
> select count(*) from table;
> 
> count
> -------
>    100
> (1 row)
> 
> 
> is correct
> 
> select count(*) from table where col::text ~~* '%text%';
> 
> count
> -------
>      1
> (1 row)
> 
> is correct.
> 
> But now if I do:
> 
> 
> select count(*) from table where col::text !~~* '%text%';
> count
> -------
>   98
> (1 row)
> 
> Shouldn't it be 99?  That is out of 100 records there is one that has
> "text" in column "col" so the !~~* should return 99 rows.  ??

NULL  value in field?

> 
> -wes

-- 
Adrian Klaver
adrian.klaver@gmail.com



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: why these results?
  2011-08-01 22:50 why these results? Wes James <comptekki@gmail.com>
@ 2011-08-01 23:01 ` Reinoud van Leeuwen <reinoud.v@n.leeuwen.net>
  2 siblings, 0 replies; 5+ messages in thread

From: Reinoud van Leeuwen @ 2011-08-01 23:01 UTC (permalink / raw)
  To: pgsql-sql

On Mon, Aug 01, 2011 at 04:50:00PM -0600, Wes James wrote:
> select count(*) from table;
> 
> count
> -------
>    100
> (1 row)
> 
> 
> is correct
> 
> select count(*) from table where col::text ~~* '%text%';
> 
> count
> -------
>      1
> (1 row)
> 
> is correct.
> 
> But now if I do:
> 
> 
> select count(*) from table where col::text !~~* '%text%';
> count
> -------
>   98
> (1 row)
> 
> Shouldn't it be 99?  That is out of 100 records there is one that has
> "text" in column "col" so the !~~* should return 99 rows.  ??

Wild guess:
select count (*) from table where col is null;
count
------
  1
(1 row)

";-)

Reinoud
-- 
__________________________________________________
"Nothing is as subjective as reality"
Reinoud van Leeuwen    reinoud.v@n.leeuwen.net
http://reinoud.van.leeuwen.net kvk 27320762
__________________________________________________



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: why these results?
  2011-08-01 22:50 why these results? Wes James <comptekki@gmail.com>
@ 2011-08-01 23:01 ` Steve Crawford <scrawford@pinpointresearch.com>
  2011-08-02 14:13   ` Re: why these results? Wes James <comptekki@gmail.com>
  2 siblings, 1 reply; 5+ messages in thread

From: Steve Crawford @ 2011-08-01 23:01 UTC (permalink / raw)
  To: pgsql-sql

On 08/01/2011 03:50 PM, Wes James wrote:
> select count(*) from table;
>
> count
> -------
>     100
> (1 row)
>
>
> is correct
>
> select count(*) from table where col::text ~~* '%text%';
>
> count
> -------
>       1
> (1 row)
>
> is correct.
>
> But now if I do:
>
>
> select count(*) from table where col::text !~~* '%text%';
> count
> -------
>    98
> (1 row)
>
> Shouldn't it be 99?  That is out of 100 records there is one that has
> "text" in column "col" so the !~~* should return 99 rows.  ??
>
> -wes
>
select count(*) from table where col is null;

(null is neither equal nor not-equal to anything, even null)

Cheers,
Steve



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: why these results?
  2011-08-01 22:50 why these results? Wes James <comptekki@gmail.com>
  2011-08-01 23:01 ` Re: why these results? Steve Crawford <scrawford@pinpointresearch.com>
@ 2011-08-02 14:13   ` Wes James <comptekki@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Wes James @ 2011-08-02 14:13 UTC (permalink / raw)
  To: pgsql-sql

Yes.  Thanks to all that responded.  That was it.

-wes

On Mon, Aug 1, 2011 at 5:01 PM, Steve Crawford
<scrawford@pinpointresearch.com> wrote:
> On 08/01/2011 03:50 PM, Wes James wrote:
>>
>> select count(*) from table;
>>
>> count
>> -------
>>    100
>> (1 row)
>>
>>
>> is correct
>>
>> select count(*) from table where col::text ~~* '%text%';
>>
>> count
>> -------
>>      1
>> (1 row)
>>
>> is correct.
>>
>> But now if I do:
>>
>>
>> select count(*) from table where col::text !~~* '%text%';
>> count
>> -------
>>   98
>> (1 row)
>>
>> Shouldn't it be 99?  That is out of 100 records there is one that has
>> "text" in column "col" so the !~~* should return 99 rows.  ??
>>
>> -wes
>>
> select count(*) from table where col is null;
>
> (null is neither equal nor not-equal to anything, even null)
>
> Cheers,
> Steve
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2011-08-02 14:13 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-08-01 22:50 why these results? Wes James <comptekki@gmail.com>
2011-08-01 23:00 ` Adrian Klaver <adrian.klaver@gmail.com>
2011-08-01 23:01 ` Reinoud van Leeuwen <reinoud.v@n.leeuwen.net>
2011-08-01 23:01 ` Steve Crawford <scrawford@pinpointresearch.com>
2011-08-02 14:13   ` Wes James <comptekki@gmail.com>

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