La consulta es la siguiente:
Código:
Un ejemplo de resultado:SELECT TOP (100) PERCENT dbo.admAgentes.CNOMBREAGENTE AS [SALES REP], dbo.admClientes.CRAZONSOCIAL AS CUSTOMER, admDocumentos_1.CSERIEDOCUMENTO AS [INVOICE SERIE], admDocumentos_1.CFOLIO AS [INVOICE FOLIO], admDocumentos_1.CFECHA AS [INVOICE DATE], admDocumentos_1.CTOTAL AS [INVOICE AMOUNT], admDocumentos_1.CTEXTOEXTRA1 AS [INVOICE PO], dbo.admDocumentos.CSERIEDOCUMENTO AS [TYPE OF PAYMENT], dbo.admDocumentos.CFOLIO AS [PAYMENT FOLIO], CASE dbo.admDocumentos.CSERIEDOCUMENTO WHEN 'PAY' THEN dbo.admAsocCargosAbonos.CIMPORTEABONO ELSE - dbo.admAsocCargosAbonos.CIMPORTEABONO END AS [PAYMENT AMOUNT], dbo.admDocumentos.CFECHA AS [PAYMENT DATE], dbo.admDocumentos.CREFERENCIA AS [CHECK NUMBER], dbo.admClientes.CCOMVENTA / 100 AS '%', CASE dbo.admDocumentos.CSERIEDOCUMENTO WHEN 'PAY' THEN dbo.admAsocCargosAbonos.CIMPORTEABONO ELSE - dbo.admAsocCargosAbonos.CIMPORTEABONO END * (dbo.admClientes.CCOMVENTA / 100) AS COMISSION, ROW_NUMBER() OVER (ORDER BY dbo.admAgentes.CNOMBREAGENTE, admDocumentos_1.CFOLIO, dbo.admDocumentos.CSERIEDOCUMENTO)as ROW FROM dbo.admDocumentos INNER JOIN dbo.admClientes ON dbo.admDocumentos.CIDCLIENTEPROVEEDOR = dbo.admClientes.CIDCLIENTEPROVEEDOR INNER JOIN dbo.admAgentes ON dbo.admClientes.CIDAGENTEVENTA = dbo.admAgentes.CIDAGENTE INNER JOIN dbo.admAsocCargosAbonos ON dbo.admDocumentos.CIDDOCUMENTO = dbo.admAsocCargosAbonos.CIDDOCUMENTOABONO INNER JOIN dbo.admDocumentos AS admDocumentos_1 ON dbo.admAsocCargosAbonos.CIDDOCUMENTOCARGO = admDocumentos_1.CIDDOCUMENTO INNER JOIN dbo.admMovimientos ON dbo.admDocumentos.CIDDOCUMENTO = dbo.admMovimientos.CIDDOCUMENTO INNER JOIN dbo.admProductos ON dbo.admMovimientos.CIDPRODUCTO = dbo.admProductos.CIDPRODUCTO WHERE (dbo.admDocumentos.CFECHA BETWEEN '01/12/2015' AND '31/12/2015') AND (dbo.admDocumentos.CIDDOCUMENTODE = 9) AND (dbo.admDocumentos.CCANCELADO = 0) AND (dbo.admAgentes.CNOMBREAGENTE <> '(Ninguno)') AND (dbo.admAgentes.CNOMBREAGENTE <> 'AMLOID CORPORATION') AND (dbo.admProductos.CCODIGOPRODUCTO <> 'F2') ORDER BY [SALES REP], [INVOICE FOLIO], [TYPE OF PAYMENT]
Código HTML:
BOE & ASSOCIATES Bluestem Brands, Inc FE 9599 2015-11-19 00:00:00.000 4365 BOE & ASSOCIATES Bluestem Brands, Inc FE 9599 2015-11-19 00:00:00.000 4365
Código HTML:
BOE & ASSOCIATES Bluestem Brands, Inc FE 9599 2015-11-19 00:00:00.000 4365 BOE & ASSOCIATES Bluestem Brands, Inc FE 9599 2015-11-19 00:00:00.000 0.00