From: Warren Little <wlittle@securitylending.com>
To: pgsql-sql@postgresql.org
Subject: Why do the two queries below return different results?
Date: 16 Jul 2003 14:52:53 -0600
Message-ID: <1058388773.5345.8.camel@localhost.localdomain> (raw)
Look at the following two queries.
select casepid, origpid
from virbcase
where date_trunc('day', origdt) >= '2003-07-01'
and date_trunc('day', origdt) <= '2003-07-31'
and origpid in (select pid from party where partyid in ('00339',
'00310',
'00320'))
and not exists (select pid from casecombo where casepid = secondpid)
select casepid, origpid
from virbcase
where date_trunc('day', origdt) >= '2003-07-01'
and date_trunc('day', origdt) <= '2003-07-31'
and origpid in (select pid from party where partyid in ('00339',
'00310',
'00320'))
and casepid not in (select secondpid from casecombo)
The second query is broken and I don't understand why.
Correlating the subquery as is done in the first query fixes it.
--
Warren Little
Senior Vice President
Secondary Marketing
Security Lending Wholesale, LC
www.securitylending.com
Tel: 866-369-7763
Fax: 866-849-8082
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: wlittle@securitylending.com
Subject: Re: Why do the two queries below return different results?
In-Reply-To: <1058388773.5345.8.camel@localhost.localdomain>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox