Re: LEAST and GREATEST functions?

Поиск
Список
Период
Сортировка
Искать
От
Greg Stark
Тема
Re: LEAST and GREATEST functions?
Дата
Msg-id
87d6gu2otf.fsf@stark.dyndns.tv
Ответ на
Список
Дерево обсуждения
LEAST and GREATEST functions? Stefan Bill <sjb26@yahoo.com>
Re: LEAST and GREATEST functions? Josh Berkus <josh@agliodbs.com>
Re: LEAST and GREATEST functions? Stefan Bill <sjb26@yahoo.com>
Re: LEAST and GREATEST functions? Greg Stark <gsstark@mit.edu>
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? Josh Berkus <josh@agliodbs.com>
Re: LEAST and GREATEST functions? Joe Conway <mail@joeconway.com>
Re: LEAST and GREATEST functions? Joe Conway <mail@joeconway.com>
Re: LEAST and GREATEST functions? Ang Chin Han <angch@bytecraft.com.my>
Re: LEAST and GREATEST functions? Tom Lane <tgl@sss.pgh.pa.us>
Re: LEAST and GREATEST functions? Ang Chin Han <angch@bytecraft.com.my>
Re: LEAST and GREATEST functions? Tom Lane <tgl@sss.pgh.pa.us>
Re: LEAST and GREATEST functions? Ang Chin Han <angch@bytecraft.com.my>
Josh Berkus  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
Дата:
FAQ