General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old May 3rd, 2007, 11:37 AM
mmorrow mmorrow is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 1 mmorrow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 18 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > SQL Join Help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway