Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2008
    Posts
    55

    Unanswered: 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'

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    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'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •