🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #721

Re: Combine data 2 records

#721
From: MrT
Date: Sun, 05 Aug 2007 23:05
59 lines
2672 bytes
Bill Todd wrote:
> SELECT ID, MAX(D1) AS D1, MAX(D2) AS D2 FROM ATABLE
> GROUP BY ID
> 
> Is that what you want?
> 

Hi:

Thanks.

Little more complicated
Here is the real query. Does not like max

This is from a stored procedure the results of which are used as a text 
(cvs) file upload to update a MySQL table on a website.

I am using the gut of the SP for testing this.

The dates I want come from the same record or two different
record at <--------.


SELECT
        CAST(m."ID" AS INTEGER) AS ID,
        'bong' || (CAST(CAST(m."ID" AS INTEGER) AS VARCHAR(10))),
        m."PWORD",
        PROPERCASESTRING(m."NAMEFIRST",''),
        PROPERCASESTRING(m."NAMELAST",''),
        PROPERCASESTRING(m."DBA",'') ,
        '' ,
        m."EMAIL" ,
        m."PHONE" ,
        CAST(m."RENEW_DTE" AS VARCHAR(10)),  <-----
        SUBSTR(m."NAMEFIRST",1,1) || 'boca' || SUBSTR(m."NAMELAST",1,1) ,
        CAST(m2."CRDRPT_RNW" AS VARCHAR(10))    <----------
FROM
     "MEMBERS" m
     LEFT OUTER JOIN "MEMPAY2" m2 ON m."ID" = m2."ID"
WHERE
  (
  (m."PWORD" IS NOT NULL) 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."CRDRPT_RNW" IS NOT NULL))) OR

     ((m2."YEARM2" = (Extract(Year from CURRENT_DATE) + 1)) AND 
((m2."DATE_PAID" IS NOT NULL) or (m2."CRDRPT_PD" IS NOT NULL)))
     )
)


ORDER BY m.ID ASC
Technical Details
Message-ID: <46b6498f@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!194.25.134.62.MISMATCH!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46b641b6@newsgroups.borland.com> <46b644a4$1@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: Sun, 05 Aug 2007 18:05:46 -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>
In-Reply-To: <46b644a4$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.39.70.99
Message-ID: <46b6498f@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1186351503 69.39.70.99 (5 Aug 2007 15:05:03 -0700)
Lines: 59
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!194.25.134.62.MISMATCH!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail