If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Using Distinct with Inner Join

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-09, 17:00
KevinYC KevinYC is offline
Registered User
 
Join Date: Aug 2008
Posts: 42
Using Distinct with Inner Join

Hello,

The query below returns duplicate rows from the inner join with TB901. I tried to add DISTINCT to the inner join as A.ENTITYID = DISTINCT B.ENTITYID and I got a syntax error. How can i return distinct rows from the second table when I use inner join?

Thank you so much!


SELECT A.ENTITYID, A.CREDTAMT, B.PRMLNAME
FROM ADUADS01.ADVTB945 A
INNER JOIN ADUADS01.ADVTB901 B ON A.ENTITYID = B.ENTITYID
WHERE A.ALLOCNBR = '3982800'
AND A.CREDTAMT > 0
AND A.LEGCRAMT = 0
AND A.TRANTYPE = 'GI'
Reply With Quote
  #2 (permalink)  
Old 01-23-09, 17:21
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
How about this?
SELECT DISTINCT A.ENTITYID, A.CREDTAMT, B.PRMLNAME
FROM ADUADS01.ADVTB945 A
INNER JOIN ADUADS01.ADVTB901 B ON A.ENTITYID = B.ENTITYID
WHERE A.ALLOCNBR = '3982800'
AND A.CREDTAMT > 0
AND A.LEGCRAMT = 0
AND A.TRANTYPE = 'GI'
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On