Re: [SQL] CASE WHEN / 6.4.2? + no doc in installed documentation - Mailing list pgsql-sql

From Fomichev Michael
Subject Re: [SQL] CASE WHEN / 6.4.2? + no doc in installed documentation
Date
Msg-id Pine.LNX.4.04.9905270956000.606-100000@ns.region.utsr
Whole thread Raw
List pgsql-sql
On Wed, 26 May 1999, Emils Klotins wrote:
> 
> I have a SELECT that needs to return a value, if another value is not null, otherwise it should 
> return a string 'N/A':
> A simpliefied version of SELECT is this:
> 
> SELECT category, CASE (WHEN category IS NULL THEN 'N/A' ELSE name) AS name FROM 
> mytable;
> 
> I get 'parse error near category'.
> 
Try this:
SELECT category, name FROM mytable WHERE category IS NOT NULL
UNION ALL
SELECT category, 'N/A' FROM mytable WHERE category IS NULL;

field `name' must have char type.



pgsql-sql by date:

Previous
From: "Steven M. Wheeler"
Date:
Subject: Re: [SQL] Re: pgsql-sql-digest V1 #225
Next
From: "Robert Chalmers"
Date:
Subject: pgsql and shopping carts - is there any development code out there?