pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Gavin Baumanis <gavinb@eclinic.com.au>
Cc: pgsql-sql@postgresql.org
Subject: Re: SELECT MAX returns wrong value
Date: Thu, 13 Dec 2007 18:32:38 -0500
Message-ID: <22441.1197588758@sss.pgh.pa.us> (raw)
In-Reply-To: <4761BBA7.7030800@eclinic.com.au>
References: <4761BBA7.7030800@eclinic.com.au>

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



view thread (3+ messages)  latest in thread

Message-ID: <22441.1197588758@sss.pgh.pa.us>
Permalink:  ../22441.1197588758@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22441.1197588758@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, gavinb@eclinic.com.au
  Subject: Re: SELECT MAX returns wrong value
  In-Reply-To: <22441.1197588758@sss.pgh.pa.us>

* 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