Re: [SQL] DIfference between max() and greatest() ?

2008-09-12 Thread Bart Degryse
max(expression) is an aggregate function (from the manual: maximum value of expression across all input values) greatest(value [, ...]) is not an aggregate function (from the manual: The GREATEST function selects the largest value from a list of any number of expressions.) So max takes the

Re: [SQL] DIfference between max() and greatest() ?

2008-09-12 Thread Peter Eisentraut
Ruben Gouveia wrote: What is the difference between these two. I know that max() is an aggregate function ... and greatest() is a normal single-row function. One works vertically, one works horizontally, if that helps you. :-) Or max() is like sum() and greatest is like +. -- Sent via

Re: [SQL] DIfference between max() and greatest() ?

2008-09-12 Thread Ruben Gouveia
Thanks Bart, Your explanation is great. Returned and Bought are of datatypes date, hence Returned would be a more recent value. On Fri, Sep 12, 2008 at 12:10 AM, Bart Degryse [EMAIL PROTECTED]wrote: max(*expression*) is an aggregate function (from the manual: maximum value of *expression*

[SQL] DIfference between max() and greatest() ?

2008-09-11 Thread Ruben Gouveia
What is the difference between these two. I know that max() is an aggregate function select model,count(distinct cars) from rc_cars where greatest(baught,returned) current_date - integer '1' group by model; Do i need to have a max () around a greatest() to make sure i get the most recent of the