Re: How to max() make null as biggest value?

Поиск
Список
Период
Сортировка
От Oliveiros
Тема Re: How to max() make null as biggest value?
Дата
Msg-id 2B9CA716C0F54A07B23E624B5424D852@marktestcr.marktest.pt
обсуждение исходный текст
Ответ на How to max() make null as biggest value?  (Feixiong Li <feixiongli@gmail.com>)
Список pgsql-sql
Howdy, Feixiong.

I dunno if this results out of the box, but try something like this

SELECT CASE WHEN (COUNT(*) <> COUNT("YourColumnName")) THEN NULL ELSE 
MAX("YourColumnName") END AS "...."
FROM t_your_table;

I don't have an example table to test so this is "air code", but if you use 
count on a column with nulls the return value is different from count(*)

HTH

Best,
Oliveiros Cristina

----- Original Message ----- 
From: "Feixiong Li" <feixiongli@gmail.com>
To: <pgsql-sql@postgresql.org>
Sent: Wednesday, April 14, 2010 5:33 AM
Subject: [SQL] How to max() make null as biggest value?


> Hi , guys ,
>
> I am newbie for sql, I have a problem when using max() function, I  need 
> get null when there are null in the value list, or return the  largest 
> value as usual, who can do this?
>
> i.e.  max([1,2,3,4,5]) => 5
> max([1,2,3,4,5,null]) => null
>
> thanks in advance!
>
> Feixiong
> feixiongli@gmail.com
>
>
>
>
>
>
>
> -- 
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql 



В списке pgsql-sql по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: How to max() make null as biggest value?
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: Problem with insert related to different schemas