Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group