Select
coalesce(T2.Salesperson_Code, 'BLANK') AS Salesperson_Code,
coalesce(T2.Company + '-' + T2.Salesperson_Code, T2.Company+'_BLANK') AS Salesperson_ID,
coalesce(T3.Description, 'Area not defined') AS [Area Description],
coalesce(T3.Code, T2.[Company]+'_BLANK') AS [Area Code], RTRIM(LTRIM(T3.Code)) + ' / ' + T3.Description AS Area,
coalesce(T2.Salesperson_Code_2, 'BLANK') AS Salesperson_Code_2,
coalesce(T2.Company + '-' + T2.Salesperson_Code_2, T2.Company+'_BLANK') AS Salesperson_2_ID,
coalesce(T4.Description, 'Area not defined') AS [Area2 Description],
coalesce(T4.Code, T2.[Company]+'_BLANK') AS [Area2 Code], RTRIM(LTRIM(T4.Code)) + ' / ' + T4.Description AS Area2,
T2.Company AS Company, T2.Name As [Customer Name], RTRIM(LTRIM(T2.No_)) + ' / ' + T2.Name As [Customer Description]
FROM
[05_Customer] AS T2 LEFT OUTER JOIN
VW_Sales_Area_Force_0 AS T3 ON T2.Salesperson_Code = T3.Salesperson_Code AND T2.Company = T3.Company,
[05_Customer] AS T5 LEFT OUTER JOIN
VW_Sales_Area_Force_1 AS T4 ON T5.Salesperson_Code = T4.Salesperson_Code AND T5.Company = T4.Company
|