it's not NULL, then what is it?

Поиск
Список
Период
Сортировка
Искать

it's not NULL, then what is it?

От:
"Tena Sakai" <tsakai@gallo.ucsf.edu>
Дата:

Hi Everybody,

I have a table called gallo.sds_seq_reg_shw,
which is like:

  canon=# \d gallo.sds_seq_reg_shw
       Table "gallo.sds_seq_reg_shw"
        Column      |  Type   | Modifiers
  ------------------+---------+-----------
   name             | text    |
   response         | text    |
   n                | integer |
   source           | text    |
   test             | text    |
   ref              | text    |
   value            | real    |
   pvalue.term      | real    |
   stars.term       | text    |
   gtclass.test     | text    |
   fclass.test      | text    |
   gtclass.ref      | text    |
   fclass.ref       | text    |
   markerid         | integer |
   maf              | real    |
   chromosome       | text    |
   physicalposition | integer |
   id               | text    |
   ctrast           | text    |
 
I am intereseted in the column maf (which is real):

  canon=# select maf from gallo.sds_seq_reg_shw
  canon-#  order by maf asc;
       maf    
  -------------
   0.000659631
   0.000659631
   0.000659631
   0.000659631
        .
  (trunacated for the interest of breivity)
        .

Another way to look at this column is:

  canon=# select maf from gallo.sds_seq_reg_shw
  canon-#  order by maf desc;
       maf    
  -------------
             
             
             
        .
  (trunacated for the interest of breivity)
        .

These rows shown are blanks, as far as I can tell.
But...

  canon=# select count(maf) from gallo.sds_seq_reg_shw;
   count
  -------
   67284
  (1 row)
 
  canon=# select count(maf) from gallo.sds_seq_reg_shw
  canon-#  where maf ISNULL;
   count
  -------
       0
  (1 row)
 
  canon=#
  canon=# select count(maf) from gallo.sds_seq_reg_shw
  canon-#  where maf NOTNULL;
   count
  -------
   67284
  (1 row)

My confusion is that if they are real and not null,
what are they?  How would I construct a query to do
something like:

 select count(maf)
   from gallo.sds_seq_reg_shw
  where maf ISBLANK;

Thank you in advance.

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu

Re: it's not NULL, then what is it?

От:
Rob Sargent <robjsargent@gmail.com>
Дата:
Tena Sakai wrote:
>
> Hi Everybody,
>
> I have a table called gallo.sds_seq_reg_shw,
> which is like:
>
>   canon=# \d gallo.sds_seq_reg_shw
>        Table "gallo.sds_seq_reg_shw"
>         Column      |  Type   | Modifiers
>   ------------------+---------+-----------
>    name             | text    |
>    response         | text    |
>    n                | integer |
>    source           | text    |
>    test             | text    |
>    ref              | text    |
>    value            | real    |
>    pvalue.term      | real    |
>    stars.term       | text    |
>    gtclass.test     | text    |
>    fclass.test      | text    |
>    gtclass.ref      | text    |
>    fclass.ref       | text    |
>    markerid         | integer |
>    maf              | real    |
>    chromosome       | text    |
>    physicalposition | integer |
>    id               | text    |
>    ctrast           | text    |
>  
> I am intereseted in the column maf (which is real):
>
>   canon=# select maf from gallo.sds_seq_reg_shw
>   canon-#  order by maf asc;
>        maf    
>   -------------
>    0.000659631
>    0.000659631
>    0.000659631
>    0.000659631
>         .
>   (trunacated for the interest of breivity)
>         .
>
> Another way to look at this column is:
>
>   canon=# select maf from gallo.sds_seq_reg_shw
>   canon-#  order by maf desc;
>        maf    
>   -------------
>              
>              
>              
>         .
>   (trunacated for the interest of breivity)
>         .
>
> These rows shown are blanks, as far as I can tell.
> But...
>
>   canon=# select count(maf) from gallo.sds_seq_reg_shw;
>    count
>   -------
>    67284
>   (1 row)
>  
>   canon=# select count(maf) from gallo.sds_seq_reg_shw
>   canon-#  where maf ISNULL;
>    count
>   -------
>        0
>   (1 row)
>  
>   canon=#
>   canon=# select count(maf) from gallo.sds_seq_reg_shw
>   canon-#  where maf NOTNULL;
>    count
>   -------
>    67284
>   (1 row)
>
> My confusion is that if they are real and not null,
> what are they?  How would I construct a query to do
> something like:
>
>  select count(maf)
>    from gallo.sds_seq_reg_shw
>   where maf ISBLANK;
>
> Thank you in advance.
>
> Regards,
>
> Tena Sakai
> tsakai@gallo.ucsf.edu
>
Maybe something like
   select ']' || maf::text || '[' -- just to see where the value   start/stops

or
   select length(maf::text)

but I suspect you're getting NAN or something unprintable in your 
environment?

Re: it's not NULL, then what is it?

От:
"Edward W. Rouse" <erouse@comsquared.com>
Дата:

Just out of curiosity did you try maf = 0?

 

Edward W. Rouse

 

From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Tena Sakai
Sent: Tuesday, June 30, 2009 6:03 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] it's not NULL, then what is it?

 

Hi Everybody,

I have a table called gallo.sds_seq_reg_shw,
which is like:

  canon=# \d gallo.sds_seq_reg_shw
       Table "gallo.sds_seq_reg_shw"
        Column      |  Type   | Modifiers
  ------------------+---------+-----------
   name             | text    |
   response         | text    |
   n                | integer |
   source           | text    |
   test             | text    |
   ref              | text    |
   value            | real    |
   pvalue.term      | real    |
   stars.term       | text    |
   gtclass.test     | text    |
   fclass.test      | text    |
   gtclass.ref      | text    |
   fclass.ref       | text    |
   markerid         | integer |
   maf              | real    |
   chromosome       | text    |
   physicalposition | integer |
   id               | text    |
   ctrast           | text    |
 
I am intereseted in the column maf (which is real):

  canon=# select maf from gallo.sds_seq_reg_shw
  canon-#  order by maf asc;
       maf    
  -------------
   0.000659631
   0.000659631
   0.000659631
   0.000659631
        .
  (trunacated for the interest of breivity)
        .

Another way to look at this column is:

  canon=# select maf from gallo.sds_seq_reg_shw
  canon-#  order by maf desc;
       maf    
  -------------
             
             
             
        .
  (trunacated for the interest of breivity)
        .

These rows shown are blanks, as far as I can tell.
But...

  canon=# select count(maf) from gallo.sds_seq_reg_shw;
   count
  -------
   67284
  (1 row)
 
  canon=# select count(maf) from gallo.sds_seq_reg_shw
  canon-#  where maf ISNULL;
   count
  -------
       0
  (1 row)
 
  canon=#
  canon=# select count(maf) from gallo.sds_seq_reg_shw
  canon-#  where maf NOTNULL;
   count
  -------
   67284
  (1 row)

My confusion is that if they are real and not null,
what are they?  How would I construct a query to do
something like:

 select count(maf)
   from gallo.sds_seq_reg_shw
  where maf ISBLANK;

Thank you in advance.

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu

Re: it's not NULL, then what is it?

От:
Steve Crawford <scrawford@pinpointresearch.com>
Дата:
...
>
>
>   canon=# select count(maf) from gallo.sds_seq_reg_shw
>   canon-#  where maf ISNULL;
>    count
>   -------
>        0
>   (1 row)
>
I believe count will only count not-null anyway so this will always 
return zero. Try count(*) instead of count(maf). Here's an example:

steve@[local]=> select * from barr;
LOG:  duration: 0.226 msa | b
---+---a | bc | d  | e
(3 rows)

steve@[local]=> select coalesce(a, 'a is null'), coalesce(b, 'b is 
null') from barr;
LOG:  duration: 0.283 mscoalesce  | coalesce
-----------+----------a         | bc         | da is null | e
(3 rows)

steve@[local]=> select count(a) from barr;
LOG:  duration: 0.339 mscount
-------    2
(1 row)

steve@[local]=> select count(*) from barr where a isnull;
LOG:  duration: 0.350 mscount
-------    1
(1 row)



Re: it's not NULL, then what is it?

От:
Thomas Kellerer <spam_eater@gmx.net>
Дата:
Steve Crawford wrote on 01.07.2009 00:39:
>>   canon=# select count(maf) from gallo.sds_seq_reg_shw
>>   canon-#  where maf ISNULL;
>>
> I believe count will only count not-null 

Correct

SELECT count(some_col)
FROM some_table;

is the same as

SELECT count(*)
FROM some_table
WHERE some_col IS NOT NULL;


Re: it's not NULL, then what is it?

От:
"Tena Sakai" <tsakai@gallo.ucsf.edu>
Дата:

Hi Rob,

> Maybe something like

>     select ']' || maf::text || '[' -- just to see where the value
>     start/stops

It prints many (1,132,691 to be exact) lines consisting of 7 space
characters followed by many lines like:
 ]0.0106383[
 ]0.0106383[
 ]0.0106383[


> or

>     select length(maf::text)

This results in many lines of 7 space characters, followed by a
bunch of 9's, 10's, 8's...

> but I suspect you're getting NAN or something unprintable in your
> environment?

Yes, me too.  But,

  canon=# select maf
  canon-#   from gallo.sds_seq_reg_shw
  canon-#  where maf = NAN;
  ERROR:  column "nan" does not exist
  LINE 3:  where maf = NAN;
                       ^

What can I put to the right of equal sign to make the query work?

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu


-----Original Message-----
From: Rob Sargent [mailto:robjsargent@gmail.com]
Sent: Tue 6/30/2009 3:24 PM
To: Tena Sakai
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] it's not NULL, then what is it?

Tena Sakai wrote:
>
> Hi Everybody,
>
> I have a table called gallo.sds_seq_reg_shw,
> which is like:
>
>   canon=# \d gallo.sds_seq_reg_shw
>        Table "gallo.sds_seq_reg_shw"
>         Column      |  Type   | Modifiers
>   ------------------+---------+-----------
>    name             | text    |
>    response         | text    |
>    n                | integer |
>    source           | text    |
>    test             | text    |
>    ref              | text    |
>    value            | real    |
>    pvalue.term      | real    |
>    stars.term       | text    |
>    gtclass.test     | text    |
>    fclass.test      | text    |
>    gtclass.ref      | text    |
>    fclass.ref       | text    |
>    markerid         | integer |
>    maf              | real    |
>    chromosome       | text    |
>    physicalposition | integer |
>    id               | text    |
>    ctrast           | text    |
> 
> I am intereseted in the column maf (which is real):
>
>   canon=# select maf from gallo.sds_seq_reg_shw
>   canon-#  order by maf asc;
>        maf   
>   -------------
>    0.000659631
>    0.000659631
>    0.000659631
>    0.000659631
>         .
>   (trunacated for the interest of breivity)
>         .
>
> Another way to look at this column is:
>
>   canon=# select maf from gallo.sds_seq_reg_shw
>   canon-#  order by maf desc;
>        maf   
>   -------------
>             
>             
>             
>         .
>   (trunacated for the interest of breivity)
>         .
>
> These rows shown are blanks, as far as I can tell.
> But...
>
>   canon=# select count(maf) from gallo.sds_seq_reg_shw;
>    count
>   -------
>    67284
>   (1 row)
> 
>   canon=# select count(maf) from gallo.sds_seq_reg_shw
>   canon-#  where maf ISNULL;
>    count
>   -------
>        0
>   (1 row)
> 
>   canon=#
>   canon=# select count(maf) from gallo.sds_seq_reg_shw
>   canon-#  where maf NOTNULL;
>    count
>   -------
>    67284
>   (1 row)
>
> My confusion is that if they are real and not null,
> what are they?  How would I construct a query to do
> something like:
>
>  select count(maf)
>    from gallo.sds_seq_reg_shw
>   where maf ISBLANK;
>
> Thank you in advance.
>
> Regards,
>
> Tena Sakai
> tsakai@gallo.ucsf.edu
>
Maybe something like

    select ']' || maf::text || '[' -- just to see where the value
    start/stops

or

    select length(maf::text)

but I suspect you're getting NAN or something unprintable in your
environment?

Re: it's not NULL, then what is it?

От:
"Tena Sakai" <tsakai@gallo.ucsf.edu>
Дата:

Hi Edward,

> Just out of curiosity did you try maf = 0?

Yes, and this is what I get:

  canon=# select maf
  canon-#   from gallo.sds_seq_reg_shw
  canon-#  where maf = 0;
   maf
  -----
  (0 rows)

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu


-----Original Message-----
From: pgsql-sql-owner@postgresql.org on behalf of Edward W. Rouse
Sent: Tue 6/30/2009 3:22 PM
To: pgsql-sql@postgresql.org
Subject: Re: [SQL] it's not NULL, then what is it?

Just out of curiosity did you try maf = 0?



Edward W. Rouse



From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]
On Behalf Of Tena Sakai
Sent: Tuesday, June 30, 2009 6:03 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] it's not NULL, then what is it?



Hi Everybody,

I have a table called gallo.sds_seq_reg_shw,
which is like:

  canon=# \d gallo.sds_seq_reg_shw
       Table "gallo.sds_seq_reg_shw"
        Column      |  Type   | Modifiers
  ------------------+---------+-----------
   name             | text    |
   response         | text    |
   n                | integer |
   source           | text    |
   test             | text    |
   ref              | text    |
   value            | real    |
   pvalue.term      | real    |
   stars.term       | text    |
   gtclass.test     | text    |
   fclass.test      | text    |
   gtclass.ref      | text    |
   fclass.ref       | text    |
   markerid         | integer |
   maf              | real    |
   chromosome       | text    |
   physicalposition | integer |
   id               | text    |
   ctrast           | text    |

I am intereseted in the column maf (which is real):

  canon=# select maf from gallo.sds_seq_reg_shw
  canon-#  order by maf asc;
       maf   
  -------------
   0.000659631
   0.000659631
   0.000659631
   0.000659631
        .
  (trunacated for the interest of breivity)
        .

Another way to look at this column is:

  canon=# select maf from gallo.sds_seq_reg_shw
  canon-#  order by maf desc;
       maf   
  -------------
            
            
            
        .
  (trunacated for the interest of breivity)
        .

These rows shown are blanks, as far as I can tell.
But...

  canon=# select count(maf) from gallo.sds_seq_reg_shw;
   count
  -------
   67284
  (1 row)

  canon=# select count(maf) from gallo.sds_seq_reg_shw
  canon-#  where maf ISNULL;
   count
  -------
       0
  (1 row)

  canon=#
  canon=# select count(maf) from gallo.sds_seq_reg_shw
  canon-#  where maf NOTNULL;
   count
  -------
   67284
  (1 row)

My confusion is that if they are real and not null,
what are they?  How would I construct a query to do
something like:

 select count(maf)
   from gallo.sds_seq_reg_shw
  where maf ISBLANK;

Thank you in advance.

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu


Re: it's not NULL, then what is it?

От:
"Tena Sakai" <tsakai@gallo.ucsf.edu>
Дата:

Hi Steve,

> I believe count will only count not-null anyway
> so this will always return zero.

Understood.  But that doesn't help me...
What I need is a query expression that I can substitute
for isblabla below:

  select maf
    from gallo.sds_seq_reg_shw
   where maf isblabla;

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu


-----Original Message-----
From: Steve Crawford [mailto:scrawford@pinpointresearch.com]
Sent: Tue 6/30/2009 3:39 PM
To: Tena Sakai
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] it's not NULL, then what is it?

...
>
>
>   canon=# select count(maf) from gallo.sds_seq_reg_shw
>   canon-#  where maf ISNULL;
>    count
>   -------
>        0
>   (1 row)
>
I believe count will only count not-null anyway so this will always
return zero. Try count(*) instead of count(maf). Here's an example:

steve@[local]=> select * from barr;
LOG:  duration: 0.226 ms
 a | b
---+---
 a | b
 c | d
   | e
(3 rows)

steve@[local]=> select coalesce(a, 'a is null'), coalesce(b, 'b is
null') from barr;
LOG:  duration: 0.283 ms
 coalesce  | coalesce
-----------+----------
 a         | b
 c         | d
 a is null | e
(3 rows)

steve@[local]=> select count(a) from barr;
LOG:  duration: 0.339 ms
 count
-------
     2
(1 row)

steve@[local]=> select count(*) from barr where a isnull;
LOG:  duration: 0.350 ms
 count
-------
     1
(1 row)



Re: it's not NULL, then what is it?

От:
"Tena Sakai" <tsakai@gallo.ucsf.edu>
Дата:

Hi Osvaldo,

> Try:
> SELECT count(*) FROM gallo.sds_seq_reg_shw;
> SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NULL;
> SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NOT NULL;

> Don't use count(maf), use count(*).

Indeed!

  canon=# SELECT count(*) FROM gallo.sds_seq_reg_shw;
    count 
  ---------
   4645647
  (1 row)

  canon=# SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NULL;
    count 
  ---------
   4578363
  (1 row)

  canon=# SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NOT NULL;
   count
  -------
   67284
  (1 row)

$ dc
4578363 67284 + p q
4645647
$

Many thanks, Osvald.

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu




-----Original Message-----
From: Osvaldo Kussama [mailto:osvaldo.kussama@gmail.com]
Sent: Tue 6/30/2009 6:49 PM
To: Tena Sakai
Subject: Re: [SQL] it's not NULL, then what is it?

2009/6/30 Tena Sakai <tsakai@gallo.ucsf.edu>:
> Hi Everybody,
>
> I have a table called gallo.sds_seq_reg_shw,
> which is like:
>
>   canon=# \d gallo.sds_seq_reg_shw
>        Table "gallo.sds_seq_reg_shw"
>         Column      |  Type   | Modifiers
>   ------------------+---------+-----------
>    name             | text    |
>    response         | text    |
>    n                | integer |
>    source           | text    |
>    test             | text    |
>    ref              | text    |
>    value            | real    |
>    pvalue.term      | real    |
>    stars.term       | text    |
>    gtclass.test     | text    |
>    fclass.test      | text    |
>    gtclass.ref      | text    |
>    fclass.ref       | text    |
>    markerid         | integer |
>    maf              | real    |
>    chromosome       | text    |
>    physicalposition | integer |
>    id               | text    |
>    ctrast           | text    |
>
> I am intereseted in the column maf (which is real):
>
>   canon=# select maf from gallo.sds_seq_reg_shw
>   canon-#  order by maf asc;
>        maf
>   -------------
>    0.000659631
>    0.000659631
>    0.000659631
>    0.000659631
>         .
>   (trunacated for the interest of breivity)
>         .
>
> Another way to look at this column is:
>
>   canon=# select maf from gallo.sds_seq_reg_shw
>   canon-#  order by maf desc;
>        maf
>   -------------
>
>
>
>         .
>   (trunacated for the interest of breivity)
>         .
>
> These rows shown are blanks, as far as I can tell.
> But...
>
>   canon=# select count(maf) from gallo.sds_seq_reg_shw;
>    count
>   -------
>    67284
>   (1 row)
>
>   canon=# select count(maf) from gallo.sds_seq_reg_shw
>   canon-#  where maf ISNULL;
>    count
>   -------
>        0
>   (1 row)
>
>   canon=#
>   canon=# select count(maf) from gallo.sds_seq_reg_shw
>   canon-#  where maf NOTNULL;
>    count
>   -------
>    67284
>   (1 row)
>
> My confusion is that if they are real and not null,
> what are they?  How would I construct a query to do
> something like:
>
>  select count(maf)
>    from gallo.sds_seq_reg_shw
>   where maf ISBLANK;
>


Try:
SELECT count(*) FROM gallo.sds_seq_reg_shw;
SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NULL;
SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NOT NULL;

Don't use count(maf), use count(*).

Osvaldo

Re: it's not NULL, then what is it?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Tena Sakai"  writes:
>>> My confusion is that if they are real and not null,
>>> what are they?

Good question.  So far as I can see these must be some value that
sprintf() is printing as spaces; but not NaN and not Infinity because
float4out checks for those first.  I would argue that this must be
a bug in sprintf.  What platform are you running on exactly?  And
for that matter, what PG version is this?
		regards, tom lane

Re: it's not NULL, then what is it?

От:
"Tena Sakai" <tsakai@gallo.ucsf.edu>
Дата:

Hi Tom,

> What platform are you running on exactly?

It is redhat linux running on Dell hardware.
uname -a returns:
Linux vixen.egcrc.org 2.6.9-78.0.1.ELsmp #1 SMP Tue Jul 22 18:01:05 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux

> And for that matter, what PG version is this?

It is 8.3.6.

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Tue 6/30/2009 7:17 PM
To: Tena Sakai
Cc: Edward W. Rouse; pgsql-sql@postgresql.org
Subject: Re: [SQL] it's not NULL, then what is it?

"Tena Sakai" <tsakai@gallo.ucsf.edu> writes:
>>> My confusion is that if they are real and not null,
>>> what are they?

Good question.  So far as I can see these must be some value that
sprintf() is printing as spaces; but not NaN and not Infinity because
float4out checks for those first.  I would argue that this must be
a bug in sprintf.  What platform are you running on exactly?  And
for that matter, what PG version is this?

                        regards, tom lane

Re: it's not NULL, then what is it?

От:
Rob Sargent <robjsargent@gmail.com>
Дата:
So they were null, and null turns out to be a seven-character blank string!?

Btw, you can change the displayed value of null with   \pset null nil
and you will seem 4+ million 'nil's in your output


Tena Sakai wrote:
>
> Hi Osvaldo,
>
> > Try:
> > SELECT count(*) FROM gallo.sds_seq_reg_shw;
> > SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NULL;
> > SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NOT NULL;
>
> > Don't use count(maf), use count(*).
>
> Indeed!
>
>   canon=# SELECT count(*) FROM gallo.sds_seq_reg_shw;
>     count 
>   ---------
>    4645647
>   (1 row)
>
>   canon=# SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NULL;
>     count 
>   ---------
>    4578363
>   (1 row)
>
>   canon=# SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NOT 
> NULL;
>    count
>   -------
>    67284
>   (1 row)
>
> $ dc
> 4578363 67284 + p q
> 4645647
> $
>
> Many thanks, Osvald.
>
> Regards,
>
> Tena Sakai
> tsakai@gallo.ucsf.edu
>
>
>
>
> -----Original Message-----
> From: Osvaldo Kussama [mailto:osvaldo.kussama@gmail.com]
> Sent: Tue 6/30/2009 6:49 PM
> To: Tena Sakai
> Subject: Re: [SQL] it's not NULL, then what is it?
>
> 2009/6/30 Tena Sakai :
> > Hi Everybody,
> >
> > I have a table called gallo.sds_seq_reg_shw,
> > which is like:
> >
> >   canon=# \d gallo.sds_seq_reg_shw
> >        Table "gallo.sds_seq_reg_shw"
> >         Column      |  Type   | Modifiers
> >   ------------------+---------+-----------
> >    name             | text    |
> >    response         | text    |
> >    n                | integer |
> >    source           | text    |
> >    test             | text    |
> >    ref              | text    |
> >    value            | real    |
> >    pvalue.term      | real    |
> >    stars.term       | text    |
> >    gtclass.test     | text    |
> >    fclass.test      | text    |
> >    gtclass.ref      | text    |
> >    fclass.ref       | text    |
> >    markerid         | integer |
> >    maf              | real    |
> >    chromosome       | text    |
> >    physicalposition | integer |
> >    id               | text    |
> >    ctrast           | text    |
> >
> > I am intereseted in the column maf (which is real):
> >
> >   canon=# select maf from gallo.sds_seq_reg_shw
> >   canon-#  order by maf asc;
> >        maf
> >   -------------
> >    0.000659631
> >    0.000659631
> >    0.000659631
> >    0.000659631
> >         .
> >   (trunacated for the interest of breivity)
> >         .
> >
> > Another way to look at this column is:
> >
> >   canon=# select maf from gallo.sds_seq_reg_shw
> >   canon-#  order by maf desc;
> >        maf
> >   -------------
> >
> >
> >
> >         .
> >   (trunacated for the interest of breivity)
> >         .
> >
> > These rows shown are blanks, as far as I can tell.
> > But...
> >
> >   canon=# select count(maf) from gallo.sds_seq_reg_shw;
> >    count
> >   -------
> >    67284
> >   (1 row)
> >
> >   canon=# select count(maf) from gallo.sds_seq_reg_shw
> >   canon-#  where maf ISNULL;
> >    count
> >   -------
> >        0
> >   (1 row)
> >
> >   canon=#
> >   canon=# select count(maf) from gallo.sds_seq_reg_shw
> >   canon-#  where maf NOTNULL;
> >    count
> >   -------
> >    67284
> >   (1 row)
> >
> > My confusion is that if they are real and not null,
> > what are they?  How would I construct a query to do
> > something like:
> >
> >  select count(maf)
> >    from gallo.sds_seq_reg_shw
> >   where maf ISBLANK;
> >
>
>
> Try:
> SELECT count(*) FROM gallo.sds_seq_reg_shw;
> SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NULL;
> SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NOT NULL;
>
> Don't use count(maf), use count(*).
>
> Osvaldo
>


Re: it's not NULL, then what is it?

От:
"Tena Sakai" <tsakai@gallo.ucsf.edu>
Дата:

Hi Rob,

> So they were null,

Yes!

> and null turns out to be a seven-character blank string!?

I don't understand how that happens.  Mr Tom Lane
hinted that it might be a bug in sprintf...

> Btw, you can change the displayed value of null with
>     \pset null nil
> and you will seem 4+ million 'nil's in your output

That is an excellent trick/skill!

  canon=# \pset null nil
  Null display is "nil".
  canon=#
  canon=# select maf from gallo.sds_seq_reg_shw
  canon-#  order by maf desc
  canon-#  limit 10;
   maf
  -----
   nil
   nil
   nil
   nil
   nil
   nil
   nil
   nil
   nil
   nil
  (10 rows)

  canon=#

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu

-----Original Message-----
From: Rob Sargent [mailto:robjsargent@gmail.com]
Sent: Wed 7/1/2009 9:36 AM
To: Tena Sakai
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] it's not NULL, then what is it?

So they were null, and null turns out to be a seven-character blank string!?

Btw, you can change the displayed value of null with
    \pset null nil
and you will seem 4+ million 'nil's in your output


Tena Sakai wrote:
>
> Hi Osvaldo,
>
> > Try:
> > SELECT count(*) FROM gallo.sds_seq_reg_shw;
> > SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NULL;
> > SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NOT NULL;
>
> > Don't use count(maf), use count(*).
>
> Indeed!
>
>   canon=# SELECT count(*) FROM gallo.sds_seq_reg_shw;
>     count
>   ---------
>    4645647
>   (1 row)
>
>   canon=# SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NULL;
>     count
>   ---------
>    4578363
>   (1 row)
>
>   canon=# SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NOT
> NULL;
>    count
>   -------
>    67284
>   (1 row)
>
> $ dc
> 4578363 67284 + p q
> 4645647
> $
>
> Many thanks, Osvald.
>
> Regards,
>
> Tena Sakai
> tsakai@gallo.ucsf.edu
>
>
>
>
> -----Original Message-----
> From: Osvaldo Kussama [mailto:osvaldo.kussama@gmail.com]
> Sent: Tue 6/30/2009 6:49 PM
> To: Tena Sakai
> Subject: Re: [SQL] it's not NULL, then what is it?
>
> 2009/6/30 Tena Sakai <tsakai@gallo.ucsf.edu>:
> > Hi Everybody,
> >
> > I have a table called gallo.sds_seq_reg_shw,
> > which is like:
> >
> >   canon=# \d gallo.sds_seq_reg_shw
> >        Table "gallo.sds_seq_reg_shw"
> >         Column      |  Type   | Modifiers
> >   ------------------+---------+-----------
> >    name             | text    |
> >    response         | text    |
> >    n                | integer |
> >    source           | text    |
> >    test             | text    |
> >    ref              | text    |
> >    value            | real    |
> >    pvalue.term      | real    |
> >    stars.term       | text    |
> >    gtclass.test     | text    |
> >    fclass.test      | text    |
> >    gtclass.ref      | text    |
> >    fclass.ref       | text    |
> >    markerid         | integer |
> >    maf              | real    |
> >    chromosome       | text    |
> >    physicalposition | integer |
> >    id               | text    |
> >    ctrast           | text    |
> >
> > I am intereseted in the column maf (which is real):
> >
> >   canon=# select maf from gallo.sds_seq_reg_shw
> >   canon-#  order by maf asc;
> >        maf
> >   -------------
> >    0.000659631
> >    0.000659631
> >    0.000659631
> >    0.000659631
> >         .
> >   (trunacated for the interest of breivity)
> >         .
> >
> > Another way to look at this column is:
> >
> >   canon=# select maf from gallo.sds_seq_reg_shw
> >   canon-#  order by maf desc;
> >        maf
> >   -------------
> >
> >
> >
> >         .
> >   (trunacated for the interest of breivity)
> >         .
> >
> > These rows shown are blanks, as far as I can tell.
> > But...
> >
> >   canon=# select count(maf) from gallo.sds_seq_reg_shw;
> >    count
> >   -------
> >    67284
> >   (1 row)
> >
> >   canon=# select count(maf) from gallo.sds_seq_reg_shw
> >   canon-#  where maf ISNULL;
> >    count
> >   -------
> >        0
> >   (1 row)
> >
> >   canon=#
> >   canon=# select count(maf) from gallo.sds_seq_reg_shw
> >   canon-#  where maf NOTNULL;
> >    count
> >   -------
> >    67284
> >   (1 row)
> >
> > My confusion is that if they are real and not null,
> > what are they?  How would I construct a query to do
> > something like:
> >
> >  select count(maf)
> >    from gallo.sds_seq_reg_shw
> >   where maf ISBLANK;
> >
>
>
> Try:
> SELECT count(*) FROM gallo.sds_seq_reg_shw;
> SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NULL;
> SELECT count(*) FROM gallo.sds_seq_reg_shw WHERE maf IS NOT NULL;
>
> Don't use count(maf), use count(*).
>
> Osvaldo
>


Re: it's not NULL, then what is it?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Tena Sakai"  writes:
>> So they were null,

> Yes!

>> and null turns out to be a seven-character blank string!?

> I don't understand how that happens.  Mr Tom Lane
> hinted that it might be a bug in sprintf...

Well, that was before I read the messages where it turned out that they
were actually nulls after all.
		regards, tom lane

Re: it's not NULL, then what is it?

От:
"Tena Sakai" <tsakai@gallo.ucsf.edu>
Дата:

Many thanks, Tom.

I wish I had known "\pset null nil" trick.
It would have saved a few unnecessary emails.

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu


-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Wed 7/1/2009 10:42 AM
To: Tena Sakai
Cc: Rob Sargent; pgsql-sql@postgresql.org
Subject: Re: [SQL] it's not NULL, then what is it?

"Tena Sakai" <tsakai@gallo.ucsf.edu> writes:
>> So they were null,

> Yes!

>> and null turns out to be a seven-character blank string!?

> I don't understand how that happens.  Mr Tom Lane
> hinted that it might be a bug in sprintf...

Well, that was before I read the messages where it turned out that they
were actually nulls after all.

                        regards, tom lane

FAQ