Article View: borland.public.interbase.sql
Article #732Re: Combine data 2 records
From: MrT
Date: Mon, 06 Aug 2007 18:10
Date: Mon, 06 Aug 2007 18:10
73 lines
3247 bytes
3247 bytes
HI Again:
I am screwing around with this trying to get the F_MAXDATE(v1,v2) to
work. That is a whole other issue which results in numeric or string
overflow or some such.
Trying to get query to work:
FROM
"MEMBERS" m
LEFT OUTER JOIN "MEMPAY2" m2 ON m."ID" = m2."ID"
INNER JOIN "MEMPAY2" m3 ON m2."ID" = m3."ID"
WHERE
(
(m."PWORD" IS NOT NULL AND m.STATUS_MEM = 'ACTIVE') AND
(
((m2."YEARM2" = (Extract(Year from CURRENT_DATE))) AND
(m2."RENEW_DATE" IS NOT NULL) and
(m2."DATE_PAID" IS NULL )) or
((m2."YEARM2" = (Extract(Year from CURRENT_DATE) - 1)) AND
(m2."RENEW_DATE" IS NOT NULL) and
(m2."DATE_PAID" IS NULL)) or
((m2."YEARM2" = (Extract(Year from CURRENT_DATE) + 1)) AND
((m2."RENEW_DATE" IS NOT NULL)) ) OR
((m2."YEARM2" = (Extract(Year from CURRENT_DATE) + 1)) AND
((m2."DATE_PAID" IS NOT NULL)))
/* )*/
OR
((m3."YEARM2" = (Extract(Year from CURRENT_DATE))) AND
(m3."CRDRPT_RNW" IS NOT NULL) and
(m3."CRDRPT_PD" IS NULL )) or
((m3."YEARM2" = (Extract(Year from CURRENT_DATE) - 1)) AND
(m3."CRDRPT_RNW" IS NOT NULL) and
(m3."CRDRPT_PD" IS NULL)) or
((m3."YEARM2" = (Extract(Year from CURRENT_DATE) + 1)) AND
(m3."CRDRPT_RNW" IS NOT NULL)) OR
((m3."YEARM2" = (Extract(Year from CURRENT_DATE) + 1)) AND
(m3."CRDRPT_PD" IS NOT NULL))
)
From this I get many, many duplicates including ones whose YEARM2
ranges from 1999 to 2008. I can't see how since I limit the records to
2007 +/- 1 in each clause (or so I think).
The first block is supposed to get all possibilities for RENEW_DATE and
DATE_PAID and pick up CRDRPT_RNW and CRDRPT_PD within the year range
while the second block gets all possibilities for CRDRPT_RNW and
CRDRPT_PD within the year range which will pick up those values from
records which do not meet the criteria in the first bloc. The F_MAXDATE
function will ferret out which value I want.
Bill Todd wrote:
> MrT wrote:
>
>> The id is the only one effectively GROUP BY.
>
> That is correct. The first query should return the the result you want
> with the GROUP BY ID added.
>
Technical Details
Message-ID:
<46b755df@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<46b641b6@newsgroups.borland.com> <46b644a4$1@newsgroups.borland.com> <46b655fa@newsgroups.borland.com> <46b662de$1@newsgroups.borland.com> <46b679a5@newsgroups.borland.com> <46b68537@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,509bc3ea097a54b X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Mon, 06 Aug 2007 13:10:34 -0500 From: MrT <contact@heat-mi.org> User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) MIME-Version: 1.0 Newsgroups: borland.public.interbase.sql Subject: Re: Combine data 2 records References: <46b641b6@newsgroups.borland.com> <46b644a4$1@newsgroups.borland.com> <46b655fa@newsgroups.borland.com> <46b662de$1@newsgroups.borland.com> <46b679a5@newsgroups.borland.com> <46b68537@newsgroups.borland.com> In-Reply-To: <46b68537@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 69.39.70.43 Message-ID: <46b755df@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1186420191 69.39.70.43 (6 Aug 2007 10:09:51 -0700) Lines: 73 Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail