Re: [SQL] CASE WHEN / 6.4.2? + no doc in installed documentation

Поиск
Список
Период
Сортировка
От Fomichev Michael
Тема Re: [SQL] CASE WHEN / 6.4.2? + no doc in installed documentation
Дата
Msg-id Pine.LNX.4.04.9905270956000.606-100000@ns.region.utsr
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: "Steven M. Wheeler"
Дата:
Сообщение: Re: [SQL] Re: pgsql-sql-digest V1 #225
Следующее
От: "Robert Chalmers"
Дата:
Сообщение: pgsql and shopping carts - is there any development code out there?