Re: How To Exclude True Values

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>, operationsengineer1(at)yahoo(dot)com, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How To Exclude True Values
Date: 2006-06-30 22:49:36
Message-ID: 20060630224936.41930.qmail@web31813.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> Also, I produced a second query using PostgreSQL:
> select a.id_i, a.ir_id, a.test, a.stamp
> from test a
> join
> (
> select max(stamp) as mstamp, id_i
> from test
> group by id_i
> ) b
> on a.stamp = b.mstamp
> where a.test = false
> ;
> -- result
> id_i | ir_id | test | stamp
> ------+-------+------+---------------------
> 4 | 8 | f | 2006-06-05 08:00:00

I found this query produced the same result. It is a list slower than the first with my small
dataset. but maybe it will improve for larger datasets?

select
t1.id_i,
t1.ir_id,
t1.test,
t1.stamp,
t1.inttest
from test as t1
where t1.stamp = ( select max(T2.stamp) from test as t2 where t2.id_i = t1.id_i)
and t1.test = 'f';

Regards,

Richard Broersma Jr.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Glaesemann 2006-07-01 00:27:07 Re: Alternative to Select in table check constraint
Previous Message Richard Broersma Jr 2006-06-30 21:55:12 Alternative to Select in table check constraint