|
Gene, I tried the query and I get this... CSNUM CAT AMT2 AMT1 CHE1000 SI 600.00 600.00 CHE1000 SI 400.00 600.00 CHE1000 SI 100.00 600.00 CHE1000 SI 500.00 600.00 I am looking for something like this... 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 seems close but yet so far.....:(...I appreciate your input though....I am still fighting.. Jake. On 4/14/06, Gene Burns <burns.gene@xxxxxxxxx> wrote: > > Try something like this: > > select table2.csnumb2, table2.cat2, table2.amt2, table1.amt1 > from table2 left join table 1 > where table1.csnumb1 = table2.csnumb2 > order by table2.csnumb2 > > Gene Burns > > > Jake M wrote: > > 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. > > > > > -- > This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list > To post a message email: RPG400-L@xxxxxxxxxxxx > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/mailman/listinfo/rpg400-l > or email: RPG400-L-request@xxxxxxxxxxxx > Before posting, please take a moment to review the archives > at http://archive.midrange.com/rpg400-l. > >
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.