question

IPERVEZ784 avatar image
IPERVEZ784 asked

SQL SERVER Inner Join Issue

The issue I am having here is when I run this query, it gives me duplicate rows as well in the result. I am using these 2 tables . TABLE Receivables has a Unique DOC NUMBER for each Customer ID. Note that Customer ID are Duplicate but Doc Number s are Unique.so that the combination of these 2 fields are not duplicate
In the same way, the 2nd Table RM20201 has also Unique Document Numbers with Customer Ids. I want to show all THOSE records from RECEIVABLE Table only whose Document Numbers (A.DOCNUMBR) are not present in TABLE RM20201, This query shows me the correct data but the result shows duplicate rows after running this query. Can you let me know why I am getting the correct data with duplicate rows?????? will appreciate your help

SELECT * FROM Receivables As A
JOIN RM20201 B
ON A.CUSTNMBR= B.CUSTNMBR
WHERE A.DOCNUMBR <> B.APTODCNM
AND A.DOCNUMBR <> B.APFRDCNM AND A.CURTRXAM <>0

sql-server-2008-r2inner join
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

KenJ avatar image KenJ commented ·

can you supply some sample data to illustrate your point? It's very common for an inner join to product duplicate rows when the data in the two tables line up in the right way.

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.