|
Pro's, I have two tables as shown below... TABLE : 1 CSNUMB1 CAT1 AMT1 CHE1000 SI 100.00 CHE1100 MR 200.00 CHE1100 MS 300.00 CHE1100 OR 100.00 CHE1100 SI 400.00 CHE1200 MS 500.00 CHE1200 SI 100.00 CHE1200 OR 600.00 CHE1200 MR 200.00 TABLE : 2 CSNUMB2 CAT2 AMT2 CHE1000 MR 600.00 CHE1000 MS 400.00 CHE1000 OR 100.00 CHE1000 SI 500.00 CHE1100 SI 600.00 CHE1100 OR 200.00 CHE1100 MS 800.00 CHE1100 MR 900.00 CNA0038 OR 100.00 CNA0038 MS 400.00 CNA0038 MR 800.00 CNA0161 OR 700.00 I am trying to build a query which would give me something like the following... CSNUM CAT AMT2 AMT1 CHE1000 MR 600.00 0.00 CHE1000 MS 400.00 0.00 CHE1000 OR 100.00 0.00 CHE1000 SI 500.00 600.00 CHE1200 MR 0.00 200.00 CHE1200 MS 0.00 500.00 CHE1200 OR 0.00 600.00 CHE1200 SI 0.00 100.00 I tried high and low but in vain. I was wondering if there was any easy way that I am missing. I am all open for a combination of queries too....Is chain a better way to go for this problem? Here is the code.... D MYSTMT S 5000A varying C EVAL mystmt ='Select csnumb1, cat1, amt1, amt2' C +'from mylib.table1 left outer' C +'join mylib.table2 on' C +' table1.csnumb1=table2.csnumb2' C +'and table1.cat1=table2.cat2' C/EXEC SQL C+ Prepare state from :mystmt C/END-EXEC C/EXEC SQL C+ DECLARE cursor SCROLL CURSOR FOR state C/END-EXEC C/EXEC SQL C+ OPEN cursor C/END-EXEC C/EXEC SQL C+ FETCH..... C/END-EXEC C EVAL *INLR = *ON C RETURN Any help would be much appreciated. Thanks in advance. Jake.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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.