select PAI_DOCUMENTO, PAI_SERIE,PAI_TIPODOC, PAI_DTEMISSAO, ITE_PRDCODIGO, PRD_DESCRICAO, PRD_NCM, ITE_TOTAL from mvto_pai A join mvto_item b on A.pai_sequ = b.pai_sequ AND ITE_CANCELADO = '1' join produtos c on b. ite_prdcodigo = c.prd_codigo where pai_filial = 1 and pai_TIPODOC IN ('NF', 'CP') AND PAI_CANCELADA = '1' AND PAI_DTEMISSAO BETWEEN '01.10.21' AND '31.10.21'