Re: SELECT MAX returns wrong value - Mailing list pgsql-sql

From Tom Lane
Subject Re: SELECT MAX returns wrong value
Date
Msg-id 22441.1197588758@sss.pgh.pa.us
Whole thread Raw
In response to SELECT MAX returns wrong value  (Gavin Baumanis <gavinb@eclinic.com.au>)
List pgsql-sql
Gavin Baumanis <gavinb@eclinic.com.au> writes:
> If I perform the following SQL

> SELECT MAX(column) FROM table WHERE expression

> and there is no match, Postgres returns a record count of 1.
> There is no value in max, it is NULL.

This is the behavior required by the SQL standard.

> Thus trying to perform some "other" tasks based on if a record was
> returned or not is proving a little difficult in this instance.

Test for null result, perhaps?
        regards, tom lane


pgsql-sql by date:

Previous
From: Gavin Baumanis
Date:
Subject: SELECT MAX returns wrong value
Next
From: Gary Stainburn
Date:
Subject: odd error updating - varchar