[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

Re: [SQL] pg_restore in java connection (auto_commit = false)

2008-09-11 Thread Emi Lu
> See: > http://www.postgresql.org/docs/8.3/interactive/explicit-locking.html > > where it says that ALTER TABLE obtains the ACCESS EXCLUSIVE lock. You > can confirm this by issuing the command of interest then running: > > SELECT * from pg_catalog.pg_locks; > > With that transaction still open,

Re: [SQL] Aggregates in WHERE clause?

2008-09-11 Thread Igor Neyman
select employee,count(distinct tasks), greatest(max(last_job_date),max(last_position_date)) from job group by employee having greatest(max(last_job_date),max(last_position_date)) < 2008-08-28 + integer '1'; From: [EMAIL PROTECTED] [mailt

Re: [SQL] Aggregates in WHERE clause?

2008-09-11 Thread Tom Lane
"Richard Broersma" <[EMAIL PROTECTED]> writes: > On Wed, Sep 10, 2008 at 4:11 PM, Ruben Gouveia <[EMAIL PROTECTED]> wrote: >> ERROR: aggregates not allowed in WHERE clause > Having clause works on agregates. If you want to force it in the > where, you need to put the groupby in a sub-query. The