Hi
I have a View which returns 255 rows. I used it in another table (Customer addresses) as I had to get a field out from this table.
When I create a new view and add in the table and tun without the field added I get the expected 255 rows. As soon as I add in the field udfTrexAccountManager t then brings 380 rows back, duplicating some of the contacts. I have tried various joins on the customerid but cannot get the right result. Any ideas please.
I have a View which returns 255 rows. I used it in another table (Customer addresses) as I had to get a field out from this table.
When I create a new view and add in the table and tun without the field added I get the expected 255 rows. As soon as I add in the field udfTrexAccountManager t then brings 380 rows back, duplicating some of the contacts. I have tried various joins on the customerid but cannot get the right result. Any ideas please.
SQL:
SELECT DISTINCT
dbo.[148-vwCRMySalesRepCodeCP].CustomerContactID, dbo.[148-vwCRMySalesRepCodeCP].CustomerCode, dbo.[148-vwCRMySalesRepCodeCP].Name AS [Customer Name],
dbo.[148-vwCRMySalesRepCodeCP].[Display Name], dbo.[148-vwCRMySalesRepCodeCP].Salutation, dbo.[148-vwCRMySalesRepCodeCP].FirstName, dbo.[148-vwCRMySalesRepCodeCP].LastName,
dbo.[148-vwCRMySalesRepCodeCP].JobTitle, dbo.[148-vwCRMySalesRepCodeCP].Telephone, dbo.[148-vwCRMySalesRepCodeCP].Email, dbo.[148-vwCRMySalesRepCodeCP].Mobile,
dbo.[148-vwCRMySalesRepCodeCP].CustomerID AS CustID, dbo.[148-vwCRMySalesRepCodeCP].SalesRepID, dbo.[148-vwCRMySalesRepCodeCP].SalesRep, dbo.[148-vwCRMySalesRepCodeCP].CusttomerType,
dbo.CustomerAddress.Deleted, dbo.[148-vwCRMySalesRepCodeCP].udfTrex, dbo.CustomerAddress.udfTrexAccountManager
FROM dbo.CustomerAddress INNER JOIN
dbo.[148-vwCRMySalesRepCodeCP] ON dbo.CustomerAddress.CustomerID = dbo.[148-vwCRMySalesRepCodeCP].CustomerID
WHERE (dbo.CustomerAddress.Deleted <> 1) AND (dbo.[148-vwCRMySalesRepCodeCP].SalesRepID = 2205)