DIfference between max() and greatest() ?

From: "Ruben Gouveia" <rubes7202(at)gmail(dot)com>
To: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: DIfference between max() and greatest() ?
Date: 2008-09-11 17:33:13
Message-ID: 51e507b0809111033j3015b7fcwd1f5922bc66b5ab5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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 two.

select model,count(distinct cars)
from rc_cars
where max(greatest(baught,returned)) < current_date - integer '1'
group by model;

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bart Degryse 2008-09-12 07:10:08 Re: DIfference between max() and greatest() ?
Previous Message Emi Lu 2008-09-11 13:48:36 Re: pg_restore in java connection (auto_commit = false)