Re: LEAST and GREATEST functions?

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: LEAST and GREATEST functions?
Дата
Msg-id 87d6gu2otf.fsf@stark.dyndns.tv
обсуждение исходный текст
Ответ на Re: LEAST and GREATEST functions?  (Josh Berkus <josh@agliodbs.com>)
Ответы Re: LEAST and GREATEST functions?  (Bruno Wolff III <bruno@wolff.to>)
Re: LEAST and GREATEST functions?  (Joe Conway <mail@joeconway.com>)
Re: LEAST and GREATEST functions?  (Ang Chin Han <angch@bytecraft.com.my>)
Список pgsql-sql
Josh Berkus <josh@agliodbs.com> writes:

> Stefan,
> 
> > I know the LEAST and GREATEST functions are not part
> > of standard SQL, but they sure were handy where I came
> > from (Oracle-land).
> 
> Um, what's wrong with MAX and MIN, exactly?

MAX and MIN are single-parameter aggregate functions. LEAST and GREATEST are
two-parameter (though in postgres they could be defined for 3 and more
parameters) scalar functions.

eg:

SELECT max(a) FROM bar 

would return a single tuple with the maximum value of a from amongst every
record. whereas:

SELECT greatest(a,b) FROM bar

would return one tuple for every record in the table with a single value
representing the greater of bar.a and bar.b.

You could define your own functions to do this but it would be tiresome to
define one for every datatype.

-- 
greg



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

Предыдущее
От: Robert Treat
Дата:
Сообщение: Re: Immutable attributes?
Следующее
От: Matthew Hixson
Дата:
Сообщение: Re: need some help with a delete statement