CREATE VIEW [dbo].[_COMISION]
AS
SELECT     dbo.SAITEMFAC.TipoFac, dbo.SAITEMFAC.NumeroD, dbo.SAITEMFAC.FechaE, ISNULL
                          ((SELECT     TOP (1) CodVend
                              FROM         dbo.SAVEND
                              WHERE     (CodVend = dbo.SAITEMFAC.CodMeca)), dbo.SAITEMFAC.CodVend) AS VEND, dbo.SAITEMFAC.CodMeca, dbo.SAITEMFAC.CodVend, dbo.SAFACT.CodClie, dbo.SAFACT.Descrip,
                      dbo.SAITEMFAC.CodItem, dbo.SAITEMFAC.Descrip1, dbo.SAITEMFAC.Cantidad, dbo.SAITEMFAC.TotalItem * dbo.SAFACT.Signo AS TOTAL, dbo.SAITEMFAC.Costo, dbo.SAITEMFAC.Precio, dbo.SAFACT.FACTOR, dbo.SAFACT.ORDENC, dbo.SAITEMFAC.esexento
FROM         dbo.SAITEMFAC INNER JOIN
                      dbo.SAFACT ON dbo.SAITEMFAC.TipoFac = dbo.SAFACT.TipoFac AND dbo.SAITEMFAC.NumeroD = dbo.SAFACT.NumeroD
WHERE     (dbo.SAITEMFAC.TipoFac IN ('A', 'B'))
