pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael S. Tibbetts <mtibbetts@head-cfa.harvard.edu>
To: pgsql-sql@postgresql.org
Subject: min() and NaN
Date: Tue, 15 Jul 2003 15:09:22 -0400
Message-ID: <3F145162.7010805@head-cfa.harvard.edu> (raw)

Hi,

I have a table containing a double precision column. That column 
contains at least one judiciously placed NaN.

I'd expect the aggregate function min() to return the minimum, valid 
numeric value.  Instead, it seems to return the minimum value from the 
subset of rows following the 'NaN'.

What's going here?  What should I expect the aggregate function min() to 
return in this case?  And why?

Any help is appreciated,
Mike


testdb=> \d min_with_nan
       Table "public.min_with_nan"
  Column |       Type       | Modifiers
--------+------------------+-----------
  col1   | double precision |

testdb=> select * from min_with_nan ;
  col1
-------
  3.141
  2.718
    NaN
     10
(4 rows)

testdb=> select min(col1) from min_with_nan ;
  min
-----
   10
(1 row)

testdb=> select min(col1) from min_with_nan where col1 != 'NaN';
   min
-------
  2.718
(1 row)




view thread (17+ messages)  latest in thread

Message-ID: <3F145162.7010805@head-cfa.harvard.edu>
Permalink:  ../3F145162.7010805@head-cfa.harvard.edu/
Also on:    postgresql.org/message-id/3F145162.7010805@head-cfa.harvard.edu

 · 

reply

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: mtibbetts@head-cfa.harvard.edu
  Subject: Re: min() and NaN
  In-Reply-To: <3F145162.7010805@head-cfa.harvard.edu>

* 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