|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
SQL Join Help
I need help joining two tables.
Table 1 contains multiple participants identified by the number par_idb. Each participant can have multiple sources numbered by sou_idi. Table 2 contains multiple participants identified by the same number par_idb, and the sources again numbered by sou_idi. For each participant and source, there can be multiple loans identified by load_cid. I am looking for the desired resultset shown. I tried performing this join: SELECT Q_BALANCE.par_idb, Q_BALANCE.sou_si, Q_BALANCE.sou_upper_title_str, Q_BALANCE.sou_idi, Q_BALANCE.source_balance, LDSOU.load_cid, LDSOU.lds_vested_rt FROM Q_BALANCE LEFT OUTER JOIN LDSOU ON (Q_BALANCE.sou_idi = LDSOU.lds_sou_id) AND (Q_BALANCE.par_idb = LDSOU.par_idb) WHERE (((Q_BALANCE.par_idb)='135367') AND ((LDSOU.load_cid)='0000018832')) Instead of getting the desired resultset, I get the incorrect resultset shown. What is the correct query? I apologize for the formatting, as I am new to posting. Thanks in advance! Table 1 ================================================== ============ par_idb sou_si sou_upper_title_str sou_idi source_balance 135367 1 EMPLOYEE 401(K) 2880 .000000 135367 2 EMPLOYER CONTRIBUTION 2881 25.056920 135367 3 ROLLOVER MONIES 2882 .000000 271223 1 EMPLOYEE 401(K) 2880 130.000000 271223 2 EMPLOYER CONTRIBUTION 2881 .000000 271223 3 ROLLOVER MONIES 2882 .000000 Table 2 ================================================== = par_idb load_cid lds_sou_id lds_vested_rt 135367 0000016473 2880 100 135367 0000016473 2882 100 135367 0000018832 2880 100 135367 0000018832 2882 100 271223 0000019112 2880 100 271223 0000019112 2881 100 271223 0000019112 2882 100 271223 0000013815 2880 100 271223 0000013815 2881 100 271223 0000013815 2882 100 Desired Resultset ================================================== ======================================= par_idb sou_si sou_upper_title_str sou_idi source_balance load_cid lds_vested_rt 135367 1 EMPLOYEE 401(K) 2880 .000000 0000018832 100 135367 2 EMPLOYER CONTRIBUTION 2881 25.056920 NULL NULL 135367 3 ROLLOVER MONIES 2882 .000000 0000018832 100 Incorrect Resultset ================================================== ======================================= par_idb sou_si sou_upper_title_str sou_idi source_balance load_cid lds_vested_rt 135367 1 EMPLOYEE 401(K) 2880 .000000 0000018832 100 135367 3 ROLLOVER MONIES 2882 .000000 0000018832 100 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > SQL Join Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|