Re: [GENERAL] How tö select a column?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Egon Frerich <egon(at)frerich(dot)eu>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: [GENERAL] How tö select a column?
Date: 2017-02-18 16:38:52
Message-ID: CAKFQuwYt+EKF5Lefzgfe5Fd3b1-3iP5424Nm2ALwHURuAyzr0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Feb 18, 2017 at 9:33 AM, Egon Frerich <egon(at)frerich(dot)eu> wrote:

> I have a table with two columns with type money. If column 'a' has an
> amount > 0 then this amount is wanted else the amount from column 'b'.

​https://www.postgresql.org/docs/9.6/static/functions-conditional.html

SELECT CASE WHEN a > 0 THEN a ELSE b END AS a_or_b FROM tbl​;

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nikolay Petrov 2017-02-18 21:01:42 Unexpected WAL-archive restore behaviour
Previous Message Egon Frerich 2017-02-18 16:33:02 How tö select a column?