Could you please help me with this issue?
I have two tables - one lists salesman data (customer account, product line and salesman's name.)
The other table has the customer account, product line brought and various sales value fields such as cost, discount, net value etc.
We can have one customer who has two salesman selling them two different product lines.
I am now trying to create a view that returns salesman, customer account, product line, sales invoice total etc.
This is my query:
SELECT dbo.SMM_IPUSALESMAN.SALESMAN, dbo.IREPORTS_MASTER.CUSTACCOUNT,
dbo.IREPORTS_MASTER.PRODUCTLINE, dbo.IREPORTS_MASTER.INVTOTAL
FROM dbo.IREPORTS_MASTER
INNER JOIN dbo.SMM_IPUSALESMAN
ON dbo.IREPORTS_MASTER.CUSTACCOUNT = dbo.SMM_IPUSALESMAN.CUSTACCOUNT
AND dbo.IREPORTS_MASTER.PRODUCTLINE = dbo.SMM_IPUSALESMAN.PRODUCTLINE`
Querying IREPORTS_MASTER returns 6000 rows, but the above query returns more hence me thinking something is wrong. I also will have a scenario where some accounts do not have a SALESMAN assigned (house accounts) so expect them to have no values but still show invoice total.
Could some explain what I am doing wrong with the query? Is the join wrong? Thanks for any help.