Re: How to return a default value if no result

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to return a default value if no result
Date: 2014-08-22 14:07:25
Message-ID: 1408716445855-5815860.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Rob Northcott wrote
> Is there a nice way of forcing a default result somehow?

The Coalesce function is your friend:

SELECT COALESCE( (SELECT subquery), <default> )

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/How-to-return-a-default-value-if-no-result-tp5815850p5815860.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Rob - TEAM Systems Ltd 2014-08-22 15:32:34 Re: How to return a default value if no result
Previous Message Rob - TEAM Systems Ltd 2014-08-22 11:29:27 Re: How to return a default value if no result