|
This may not be the most elegant piece of code ever written, but if
I understand your table structure correctly, I think that it will do
what you want. If you want a sample DB, let me know. SET VAR vnumdates INTEGER = NULL SET VAR vnumtrans INTEGER = NULL SET VAR vcurtrans INTEGER = NULL SET VAR vcurnote NOTE = NULL SET VAR vnewnote VARCHAR = NULL SET VAR vcurdate DATE = NULL SET WHILEOPT OFF SELECT COUNT (DISTINCT trdate) INTO vnumdates FROM oldtrans SELECT MIN (ADDDAY(trdate,-1)) INTO vcurdate FROM oldtrans WHILE vnumdates <> 0 THEN SELECT MIN trdate INTO vcurdate FROM oldtrans WHERE trdate > .vcurdate SELECT COUNT (DISTINCT vernum) INTO vnumtrans FROM oldtrans WHERE trdate = .vcurdate SELECT MIN (vernum - 1) INTO vcurtrans FROM oldtrans WHERE trdate = .vcurdate SET VAR vnewnote = NULL WHILE vnumtrans <> 0 THEN SELECT MIN vernum INTO vcurtrans FROM oldtrans WHERE trdate = .vcurdate AND vernum > .vcurtrans SELECT trnotes INTO vcurnote FROM oldtrans WHERE vernum = .vcurtrans IF vnumtrans = 1 THEN SET VAR vnewnote = .vnewnote + .vcurnote ELSE SET VAR vnewnote = .vnewnote + .vcurnote + (CHAR(10)) ENDIF SET VAR vnumtrans = .vnumtrans - 1 ENDWHILE SET VAR vnumdates = .vnumdates - 1 INSERT INTO newtrans (txdate,txnotes) VALUES (.vcurdate,.vnewnote) ENDWHILE SET WHILEOPT ON CLEAR VARIABLES vnumdates,vnumtrans,vcurtrans,vcurnote,vnewnote,vcurdate RETURN Jason Kramer University Archives and Records Management 002 Pearson Hall (302) 831 - 3127 (voice) (302) 831 - 6903 (fax) On 3/25/2010 12:49 PM, MDRD wrote:
|
- [RBASE-L] - Re: Merge 2 rows into one jan johansen
- [RBASE-L] - Re: Merge 2 rows into one MDRD
- [RBASE-L] - Re: Merge 2 rows into one jan johansen
- [RBASE-L] - Re: Merge 2 rows into one Jason Kramer
- [RBASE-L] - Re: Merge 2 rows into one MDRD
- [RBASE-L] - Re: Merge 2 rows into one Emmitt Dove
- [RBASE-L] - Re: Merge 2 rows into one MDRD
- [RBASE-L] - Re: Merge 2 rows into one Bill Downall
- [RBASE-L] - Re: Merge 2 rows into one jan johansen
- [RBASE-L] - Re: Merge 2 rows into one Jason Kramer
- [RBASE-L] - Re: Merge 2 rows into one Javier Valencia
- [RBASE-L] - Re: Merge 2 rows into one MDRD
- [RBASE-L] - Re: Merge 2 rows into one Jay Ward
- [RBASE-L] - Re: Merge 2 rows into one jan johansen

