|
Denis has it. I'll fix up the syntax a bit and add a join to bring
the data together with MFLD columns for the main columns, and ATR
columns for the attribute columns. You could also use a subselect if
you're only bringing in one column from the main table. I didn't test
any of this...
select a.ATR1, a.ATR2, b.MFLD1, b.MFLD2
from FileX a
where a.RcdTyp='ATTRIBUTE'
left outer join lateral
(select MFLD1, MFLD2
from FileX b
where RRN(b)<RRN(a)
and RcdTyp='MAIN'
order by RRN(B)
fetch first row only) B
on 1=1
Alternative as subselect:
select a.ATR1, a.ATR2
, (select MFLD1
from FileX b
where RRN(b)<RRN(a)
and RcdTyp='MAIN'
order by RRN(b)
fetch first row only)
from FileX a
where a.RcdTyp='ATTRIBUTE'
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.