CREATE VIEW [dbo].[ApiVindicationView] as
select top 100 percent payment.* ,
ISNULL(person.Name,'') Name, ISNULL(person.LastName,'') LastName, ISNULL(person.Position,'') Position, ISNULL(person.Phone,'') Phone, ISNULL(person.Phone2,'') Phone2, ISNULL(person.Email,'') Email
from dbo.ApiPaymentView payment
LEFT OUTER JOIN dbo.[ApiCustomerPersonsView]  person ON person.CustId = payment.CustId and person.NotyficationType>0
ORDER BY VendorId, CustId, DueDate, ToPay DESC

GO
