Segue estrutura CREATE TABLE `tbbehavior` (
`NuCpfCnpj` varchar(11) DEFAULT NULL,
`CdProduto` int(11) DEFAULT NULL,
`TpCartao` int(11) DEFAULT NULL,
`NuConta` decimal(9,0) DEFAULT NULL,
`DtCorte` varchar(6) DEFAULT NULL,
`StCartaoM0` decimal(2,0) DEFAULT NULL,
`StCartaoM1` decimal(2,0) DEFAULT NULL,
`StCartaoM2` decimal(2,0) DEFAULT NULL,
`StCartaoM3` decimal(2,0) DEFAULT NULL,
`StCartaoM4` decimal(2,0) DEFAULT NULL,
`StCartaoM5` decimal(2,0) DEFAULT NULL,
`StCartaoM6` decimal(2,0) DEFAULT NULL,
`StCartaoM7` decimal(2,0) DEFAULT NULL,
`StCartaoM8` decimal(2,0) DEFAULT NULL,
`StCartaoM9` decimal(2,0) DEFAULT NULL,
`StCartaoM10` decimal(2,0) DEFAULT NULL,
`StCartaoM11` decimal(2,0) DEFAULT NULL,
`StContaM0` decimal(2,0) DEFAULT NULL,
`StContaM1` decimal(2,0) DEFAULT NULL,
`StContaM2` decimal(2,0) DEFAULT NULL,
`StContaM3` decimal(2,0) DEFAULT NULL,
`StContaM4` decimal(2,0) DEFAULT NULL,
`StContaM5` decimal(2,0) DEFAULT NULL,
`StContaM6` decimal(2,0) DEFAULT NULL,
`StContaM7` decimal(2,0) DEFAULT NULL,
`StContaM8` decimal(2,0) DEFAULT NULL,
`StContaM9` decimal(2,0) DEFAULT NULL,
`StContaM10` decimal(2,0) DEFAULT NULL,
`StContaM11` decimal(2,0) DEFAULT NULL,
`DtCorteM0` date DEFAULT NULL,
`DtCorteM1` date DEFAULT NULL,
`DtCorteM2` date DEFAULT NULL,
`DtCorteM3` date DEFAULT NULL,
`DtCorteM4` date DEFAULT NULL,
`DtCorteM5` date DEFAULT NULL,
`DtCorteM6` date DEFAULT NULL,
`DtCorteM7` date DEFAULT NULL,
`DtCorteM8` date DEFAULT NULL,
`DtCorteM9` date DEFAULT NULL,
`DtCorteM10` date DEFAULT NULL,
`DtCorteM11` date DEFAULT NULL,
`DtAberturaCta` date DEFAULT NULL,
`DtNascimento` date DEFAULT NULL,
`CdProfissao` decimal(3,0) DEFAULT NULL,
`QtdAdicionais` decimal(3,0) DEFAULT NULL,
`FlagSeguroPerdaRoubo` varchar(16) DEFAULT NULL,
`DtPrimeiraTransacao` date DEFAULT NULL,
`DtPrimeiroDesblq` date DEFAULT NULL,
`CdGrupoRelacionamento` decimal(2,0) DEFAULT NULL,
`GrpRelacionamento` varchar(30) DEFAULT NULL,
`DtEnquadramento` date DEFAULT NULL,
`VlrCL` decimal(10,2) DEFAULT NULL,
`CEP` varchar(9) DEFAULT NULL,
`SaldoFaturaM0` decimal(10,2) DEFAULT NULL,
`SaldoFaturaM1` decimal(10,2) DEFAULT NULL,
`SaldoFaturaM2` decimal(10,2) DEFAULT NULL,
`SaldoFaturaM3` decimal(10,2) DEFAULT NULL,
`SaldoFaturaM4` decimal(10,2) DEFAULT NULL,
`SaldoFaturaM5` decimal(10,2) DEFAULT NULL,
`SaldoFaturaM6` decimal(10,2) DEFAULT NULL,
`SaldoFaturaM7` decimal(10,2) DEFAULT NULL,
`SaldoFaturaM8` decimal(10,2) DEFAULT NULL,
`SaldoFaturaM9` decimal(10,2) DEFAULT NULL,
`SaldoFaturaM10` decimal(10,2) DEFAULT NULL,
`SaldoFaturaM11` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM0` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM1` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM2` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM3` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM4` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM5` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM6` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM7` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM8` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM9` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM10` decimal(10,2) DEFAULT NULL,
`VlrJuroMultaM11` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM0` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM1` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM2` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM3` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM4` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM5` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM6` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM7` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM8` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM9` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM10` decimal(10,2) DEFAULT NULL,
`VlrJurosFinanciamentoM11` decimal(10,2) DEFAULT NULL,
`DiasAtrasoM0` decimal(4,0) DEFAULT NULL,
`DiasAtrasoM1` decimal(4,0) DEFAULT NULL,
`DiasAtrasoM2` decimal(4,0) DEFAULT NULL,
`DiasAtrasoM3` decimal(4,0) DEFAULT NULL,
`DiasAtrasoM4` decimal(4,0) DEFAULT NULL,
`DiasAtrasoM5` decimal(4,0) DEFAULT NULL,
`DiasAtrasoM6` decimal(4,0) DEFAULT NULL,
`DiasAtrasoM7` decimal(4,0) DEFAULT NULL,
`DiasAtrasoM8` decimal(4,0) DEFAULT NULL,
`DiasAtrasoM9` decimal(4,0) DEFAULT NULL,
`DiasAtrasoM10` decimal(4,0) DEFAULT NULL,
`DiasAtrasoM11` decimal(4,0) DEFAULT NULL,
`DiasAtrasoCorteM0` decimal(5,0) DEFAULT NULL,
`DiasAtrasoCorteM1` decimal(5,0) DEFAULT NULL,
`DiasAtrasoCorteM2` decimal(5,0) DEFAULT NULL,
`DiasAtrasoCorteM3` decimal(5,0) DEFAULT NULL,
`DiasAtrasoCorteM4` decimal(5,0) DEFAULT NULL,
`DiasAtrasoCorteM5` decimal(5,0) DEFAULT NULL,
`DiasAtrasoCorteM6` decimal(5,0) DEFAULT NULL,
`DiasAtrasoCorteM7` decimal(5,0) DEFAULT NULL,
`DiasAtrasoCorteM8` decimal(5,0) DEFAULT NULL,
`DiasAtrasoCorteM9` decimal(5,0) DEFAULT NULL,
`DiasAtrasoCorteM10` decimal(5,0) DEFAULT NULL,
`DiasAtrasoCorteM11` decimal(5,0) DEFAULT NULL,
`VlrSaqueCashM0` decimal(10,2) DEFAULT NULL,
`VlrSaqueCashM1` decimal(10,2) DEFAULT NULL,
`VlrSaqueCashM2` decimal(10,2) DEFAULT NULL,
`VlrSaqueCashM3` decimal(10,2) DEFAULT NULL,
`VlrSaqueCashM4` decimal(10,2) DEFAULT NULL,
`VlrSaqueCashM5` decimal(10,2) DEFAULT NULL,
`VlrSaqueCashM6` decimal(10,2) DEFAULT NULL,
`VlrSaqueCashM7` decimal(10,2) DEFAULT NULL,
`VlrSaqueCashM8` decimal(10,2) DEFAULT NULL,
`VlrSaqueCashM9` decimal(10,2) DEFAULT NULL,
`VlrSaqueCashM10` decimal(10,2) DEFAULT NULL,
`VlrSaqueCashM11` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM0` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM1` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM2` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM3` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM4` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM5` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM6` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM7` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM8` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM9` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM10` decimal(10,2) DEFAULT NULL,
`VlrPgtoCorteM11` decimal(10,2) DEFAULT NULL,
`VlrComprasM0` decimal(10,2) DEFAULT NULL,
`VlrComprasM1` decimal(10,2) DEFAULT NULL,
`VlrComprasM2` decimal(10,2) DEFAULT NULL,
`VlrComprasM3` decimal(10,2) DEFAULT NULL,
`VlrComprasM4` decimal(10,2) DEFAULT NULL,
`VlrComprasM5` decimal(10,2) DEFAULT NULL,
`VlrComprasM6` decimal(10,2) DEFAULT NULL,
`VlrComprasM7` decimal(10,2) DEFAULT NULL,
`VlrComprasM8` decimal(10,2) DEFAULT NULL,
`VlrComprasM9` decimal(10,2) DEFAULT NULL,
`VlrComprasM10` decimal(10,2) DEFAULT NULL,
`VlrComprasM11` decimal(10,2) DEFAULT NULL,
`QtdComprasCorteM0` decimal(3,0) DEFAULT NULL,
`QtdComprasCorteM1` decimal(3,0) DEFAULT NULL,
`QtdComprasCorteM2` decimal(3,0) DEFAULT NULL,
`QtdComprasCorteM3` decimal(3,0) DEFAULT NULL,
`QtdComprasCorteM4` decimal(3,0) DEFAULT NULL,
`QtdComprasCorteM5` decimal(3,0) DEFAULT NULL,
`QtdComprasCorteM6` decimal(3,0) DEFAULT NULL,
`QtdComprasCorteM7` decimal(3,0) DEFAULT NULL,
`QtdComprasCorteM8` decimal(3,0) DEFAULT NULL,
`QtdComprasCorteM9` decimal(3,0) DEFAULT NULL,
`QtdComprasCorteM10` decimal(3,0) DEFAULT NULL,
`QtdComprasCorteM11` decimal(3,0) DEFAULT NULL,
`LimiteCorteM0` decimal(10,2) DEFAULT NULL,
`LimiteCorteM1` decimal(10,2) DEFAULT NULL,
`LimiteCorteM2` decimal(10,2) DEFAULT NULL,
`LimiteCorteM3` decimal(10,2) DEFAULT NULL,
`LimiteCorteM4` decimal(10,2) DEFAULT NULL,
`LimiteCorteM5` decimal(10,2) DEFAULT NULL,
`LimiteCorteM6` decimal(10,2) DEFAULT NULL,
`LimiteCorteM7` decimal(10,2) DEFAULT NULL,
`LimiteCorteM8` decimal(10,2) DEFAULT NULL,
`LimiteCorteM9` decimal(10,2) DEFAULT NULL,
`LimiteCorteM10` decimal(10,2) DEFAULT NULL,
`LimiteCorteM11` decimal(10,2) DEFAULT NULL,
`SldParVencCortM0` decimal(10,2) DEFAULT NULL,
`SldParVencCortM1` decimal(10,2) DEFAULT NULL,
`SldParVencCortM2` decimal(10,2) DEFAULT NULL,
`SldParVencCortM3` decimal(10,2) DEFAULT NULL,
`SldParVencCortM4` decimal(10,2) DEFAULT NULL,
`SldParVencCortM5` decimal(10,2) DEFAULT NULL,
`SldParVencCortM6` decimal(10,2) DEFAULT NULL,
`SldParVencCortM7` decimal(10,2) DEFAULT NULL,
`SldParVencCortM8` decimal(10,2) DEFAULT NULL,
`SldParVencCortM9` decimal(10,2) DEFAULT NULL,
`SldParVencCortM10` decimal(10,2) DEFAULT NULL,
`SldParVencCortM11` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM0` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM1` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM2` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM3` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM4` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM5` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM6` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM7` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM8` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM9` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM10` decimal(10,2) DEFAULT NULL,
`VlrAnuidadeCorteM11` decimal(10,2) DEFAULT NULL,
`IndicativoFaturamentoM0` varchar(1) DEFAULT NULL,
`IndicativoFaturamentoM1` varchar(1) DEFAULT NULL,
`IndicativoFaturamentoM2` varchar(1) DEFAULT NULL,
`IndicativoFaturamentoM3` varchar(1) DEFAULT NULL,
`IndicativoFaturamentoM4` varchar(1) DEFAULT NULL,
`IndicativoFaturamentoM5` varchar(1) DEFAULT NULL,
`IndicativoFaturamentoM6` varchar(1) DEFAULT NULL,
`IndicativoFaturamentoM7` varchar(1) DEFAULT NULL,
`IndicativoFaturamentoM8` varchar(1) DEFAULT NULL,
`IndicativoFaturamentoM9` varchar(1) DEFAULT NULL,
`IndicativoFaturamentoM10` varchar(1) DEFAULT NULL,
`IndicativoFaturamentoM11` varchar(1) DEFAULT NULL,
`DtPgtoCorteM0` date DEFAULT NULL,
`DtPgtoCorteM1` date DEFAULT NULL,
`DtPgtoCorteM2` date DEFAULT NULL,
`DtPgtoCorteM3` date DEFAULT NULL,
`DtPgtoCorteM4` date DEFAULT NULL,
`DtPgtoCorteM5` date DEFAULT NULL,
`DtPgtoCorteM6` date DEFAULT NULL,
`DtPgtoCorteM7` date DEFAULT NULL,
`DtPgtoCorteM8` date DEFAULT NULL,
`DtPgtoCorteM9` date DEFAULT NULL,
`DtPgtoCorteM10` date DEFAULT NULL,
`DtPgtoCorteM11` date DEFAULT NULL,
`DtVencCorteM0` date DEFAULT NULL,
`DtVencCorteM1` date DEFAULT NULL,
`DtVencCorteM2` date DEFAULT NULL,
`DtVencCorteM3` date DEFAULT NULL,
`DtVencCorteM4` date DEFAULT NULL,
`DtVencCorteM5` date DEFAULT NULL,
`DtVencCorteM6` date DEFAULT NULL,
`DtVencCorteM7` date DEFAULT NULL,
`DtVencCorteM8` date DEFAULT NULL,
`DtVencCorteM9` date DEFAULT NULL,
`DtVencCorteM10` date DEFAULT NULL,
`DtVencCorteM11` date DEFAULT NULL,
`VlrPgtoMinFaturaCorteM0` decimal(10,2) DEFAULT NULL,
`VlrPgtoMinFaturaCorteM1` decimal(10,2) DEFAULT NULL,
`VlrPgtoMinFaturaCorteM2` decimal(10,2) DEFAULT NULL,
`VlrPgtoMinFaturaCorteM3` decimal(10,2) DEFAULT NULL,
`VlrPgtoMinFaturaCorteM4` decimal(10,2) DEFAULT NULL,
`VlrPgtoMinFaturaCorteM5` decimal(10,2) DEFAULT NULL,
`VlrPgtoMinFaturaCorteM6` decimal(10,2) DEFAULT NULL,
`VlrPgtoMinFaturaCorteM7` decimal(10,2) DEFAULT NULL,
`VlrPgtoMinFaturaCorteM8` decimal(10,2) DEFAULT NULL,
`VlrPgtoMinFaturaCorteM9` decimal(10,2) DEFAULT NULL,
`VlrPgtoMinFaturaCorteM10` decimal(10,2) DEFAULT NULL,
`VlrPgtoMinFaturaCorteM11` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM0` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM1` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM2` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM3` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM4` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM5` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM6` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM7` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM8` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM9` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM10` decimal(10,2) DEFAULT NULL,
`VlrLimiteSaqueCorteM11` decimal(10,2) DEFAULT NULL,
`SldDispCorteM0` decimal(10,2) DEFAULT NULL,
`SldDispCorteM1` decimal(10,2) DEFAULT NULL,
`SldDispCorteM2` decimal(10,2) DEFAULT NULL,
`SldDispCorteM3` decimal(10,2) DEFAULT NULL,
`SldDispCorteM4` decimal(10,2) DEFAULT NULL,
`SldDispCorteM5` decimal(10,2) DEFAULT NULL,
`SldDispCorteM6` decimal(10,2) DEFAULT NULL,
`SldDispCorteM7` decimal(10,2) DEFAULT NULL,
`SldDispCorteM8` decimal(10,2) DEFAULT NULL,
`SldDispCorteM9` decimal(10,2) DEFAULT NULL,
`SldDispCorteM10` decimal(10,2) DEFAULT NULL,
`SldDispCorteM11` decimal(10,2) DEFAULT NULL,
KEY `IDXBEHAVIOR01` (`NuCpfCnpj`,`CdProduto`,`TpCartao`,`NuConta`,`DtCorte`),
KEY `dio_atraso010` (`DiasAtrasoCorteM0`,`DiasAtrasoCorteM1`,`DiasAtrasoCorteM2`,`DiasAtrasoCorteM3`,`DtEnquadramento`,`VlrJurosFinanciamentoM4`,`VlrJurosFinanciamentoM5`,`VlrJurosFinanciamentoM6`,`VlrJurosFinanciamentoM7`,`VlrJurosFinanciamentoM8`,`VlrJurosFinanciamentoM9`,`VlrJurosFinanciamentoM10`,`VlrJurosFinanciamentoM11`),
KEY `dio_bati001` (`DtCorteM0`),
KEY `Idx100` (`DtCorte`),
KEY `Idx101` (`NuCpfCnpj`),
KEY `Idx102` (`NuConta`),
KEY `Idx103` (`CdProduto`),
KEY `Idx104` (`TpCartao`),
KEY `Idx105` (`DtCorteM0`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*Table structure for table `tbvariaveiscalculadas` */
CREATE TABLE `tbvariaveiscalculadas` (
`NuCpfCnpj` varchar(11) DEFAULT NULL,
`CdProduto` int(11) DEFAULT NULL,
`TpCartao` int(11) DEFAULT NULL,
`NuConta` decimal(9,0) DEFAULT NULL,
`DtCorte` varchar(6) DEFAULT NULL,
`IdadeTitular` decimal(16,0) DEFAULT NULL,
`LogTitular` decimal(16,2) DEFAULT NULL,
`Cep2` varchar(2) DEFAULT NULL,
`Cep6` varchar(6) DEFAULT NULL,
`IdadeConta` int(11) DEFAULT NULL,
`LogConta` decimal(16,2) DEFAULT NULL,
`NuFaturasM0` int(11) DEFAULT NULL,
`NuFaturasM3` int(11) DEFAULT NULL,
`NuFaturasM6` int(11) DEFAULT NULL,
`NuFaturasM9` int(11) DEFAULT NULL,
`NuMesesComprasM0` int(11) DEFAULT NULL,
`NuMesesComprasM3` int(11) DEFAULT NULL,
`NuMesesComprasM6` int(11) DEFAULT NULL,
`NuMesesComprasM9` int(11) DEFAULT NULL,
`NuMesesSaldoM0` int(11) DEFAULT NULL,
`NuMesesSaldoM3` int(11) DEFAULT NULL,
`NuMesesSaldoM6` int(11) DEFAULT NULL,
`NuMesesSaldoM9` int(11) DEFAULT NULL,
`UtilizacaoM3` decimal(10,2) DEFAULT NULL,
`UtilizacaoM6` decimal(10,2) DEFAULT NULL,
`UtilizacaoM9` decimal(10,2) DEFAULT NULL,
`NuBucket1M3` int(11) DEFAULT NULL,
`NuBucket1M6` int(11) DEFAULT NULL,
`NuBucket1M9` int(11) DEFAULT NULL,
`NuBucket2M3` int(11) DEFAULT NULL,
`NuBucket2M6` int(11) DEFAULT NULL,
`NuBucket2M9` int(11) DEFAULT NULL,
`CashM0` varchar(1) DEFAULT NULL,
`CashM3` varchar(1) DEFAULT NULL,
`CashM6` varchar(1) DEFAULT NULL,
`CashM9` varchar(1) DEFAULT NULL,
`PercCashM0` decimal(10,2) DEFAULT NULL,
`PercCashM3` decimal(10,2) DEFAULT NULL,
`PercCashM6` decimal(10,2) DEFAULT NULL,
`PercCashM9` decimal(10,2) DEFAULT NULL,
`SaqueM0` decimal(10,2) DEFAULT NULL,
`SaqueM3` decimal(10,2) DEFAULT NULL,
`SaqueM6` decimal(10,2) DEFAULT NULL,
`SaqueM9` decimal(10,2) DEFAULT NULL,
`AtrasoM0` int(11) DEFAULT NULL,
`AtrasoM3` int(11) DEFAULT NULL,
`AtrasoM6` int(11) DEFAULT NULL,
`AtrasoM9` int(11) DEFAULT NULL,
`TempUtilizacao` int(11) DEFAULT NULL,
`NuReduSaldoM3` int(11) DEFAULT NULL,
`NuReduSaldoM6` int(11) DEFAULT NULL,
`NuReduSaldoM9` int(11) DEFAULT NULL,
`NuAumenSaldoM3` int(11) DEFAULT NULL,
`NuAumenSaldoM6` int(11) DEFAULT NULL,
`NuAumenSaldoM9` int(11) DEFAULT NULL,
`NuPagtoM3` int(11) DEFAULT NULL,
`NuPagtoM6` int(11) DEFAULT NULL,
`NuPagtoM9` int(11) DEFAULT NULL,
`NuSemPgtoM3` int(11) DEFAULT NULL,
`NuSemPgtoM6` int(11) DEFAULT NULL,
`NuSemPgtoM9` int(11) DEFAULT NULL,
`PercSaldoPgtoM0` decimal(10,2) DEFAULT NULL,
`PercSaldoPgtoM3` decimal(10,2) DEFAULT NULL,
`PercSaldoPgtoM6` decimal(10,2) DEFAULT NULL,
`PercSaldoPgtoM9` decimal(10,2) DEFAULT NULL,
`NuFinaciamentoM0` int(11) DEFAULT NULL,
`NuFinaciamentoM3` int(11) DEFAULT NULL,
`NuFinaciamentoM6` int(11) DEFAULT NULL,
`NuFinaciamentoM9` int(11) DEFAULT NULL,
`PercenComprasM0` decimal(10,2) DEFAULT NULL,
`PercenComprasM3` decimal(10,2) DEFAULT NULL,
`PercenComprasM6` decimal(10,2) DEFAULT NULL,
`PercenComprasM9` decimal(10,2) DEFAULT NULL,
`PercenFinanciadoM0` decimal(10,2) DEFAULT NULL,
`PercenFinanciadoM3` decimal(10,2) DEFAULT NULL,
`PercenFinanciadoM6` decimal(10,2) DEFAULT NULL,
`PercenFinanciadoM9` decimal(10,2) DEFAULT NULL,
`PercenLimiteM3` decimal(10,2) DEFAULT NULL,
`PercenLimiteM6` decimal(10,2) DEFAULT NULL,
`PercenLimiteM9` decimal(10,2) DEFAULT NULL,
`NuComprasM0` decimal(10,2) DEFAULT NULL,
`NuComprasM3` decimal(10,2) DEFAULT NULL,
`NuComprasM6` decimal(10,2) DEFAULT NULL,
`NuComprasM9` decimal(10,2) DEFAULT NULL,
`NuOverlimitM0` int(11) DEFAULT NULL,
`NuOverlimitM3` int(11) DEFAULT NULL,
`NuOverlimitM6` int(11) DEFAULT NULL,
`NuOverlimitM9` int(11) DEFAULT NULL,
`NuPagtoTotalM0` int(11) DEFAULT NULL,
`NuPagtoTotalM3` int(11) DEFAULT NULL,
`NuPagtoTotalM6` int(11) DEFAULT NULL,
`NuPagtoTotalM9` int(11) DEFAULT NULL,
`PercSaldoM3` decimal(10,2) DEFAULT NULL,
`PercSaldoM6` decimal(10,2) DEFAULT NULL,
`PercSaldoM9` decimal(10,2) DEFAULT NULL,
`NuAumentoRefinM3` int(11) DEFAULT NULL,
`NuAumentoRefinM6` int(11) DEFAULT NULL,
`NuAumentoRefinM9` int(11) DEFAULT NULL,
`NuDemiRefinM3` int(11) DEFAULT NULL,
`NuDemiRefinM6` int(11) DEFAULT NULL,
`NuDemiRefinM9` int(11) DEFAULT NULL,
`NuSemMudanRefinM3` int(11) DEFAULT NULL,
`NuSemMudanRefinM6` int(11) DEFAULT NULL,
`NuSemMudanRefinM9` int(11) DEFAULT NULL,
`PercMaiorRefinM3` decimal(10,2) DEFAULT NULL,
`PercMaiorRefinM6` decimal(10,2) DEFAULT NULL,
`PercMaiorRefinM9` decimal(10,2) DEFAULT NULL,
`UltimaUtilizacao` decimal(10,2) DEFAULT NULL,
`AtrasoCorrenteM3` decimal(10,2) DEFAULT NULL,
`AtrasoCorrenteM6` decimal(10,2) DEFAULT NULL,
`AtrasoCorrenteM9` decimal(10,2) DEFAULT NULL,
`CrescAtrasoM3` int(11) DEFAULT NULL,
`CrescAtrasoM6` int(11) DEFAULT NULL,
`CrescAtrasoM9` int(11) DEFAULT NULL,
`DiminAtrasoM3` int(11) DEFAULT NULL,
`DiminAtrasoM6` int(11) DEFAULT NULL,
`DiminAtrasoM9` int(11) DEFAULT NULL,
`SemMudancaAtrasoM3` int(11) DEFAULT NULL,
`SemMudancaAtrasoM6` int(11) DEFAULT NULL,
`SemMudancaAtrasoM9` int(11) DEFAULT NULL,
`NuMedioCompras` decimal(10,2) DEFAULT NULL,
`SaldoMedioM3` decimal(10,2) DEFAULT NULL,
`SaldoMedioM6` decimal(10,2) DEFAULT NULL,
`SaldoMedioM9` decimal(10,2) DEFAULT NULL,
`NuFaturouCorr` int(11) DEFAULT NULL,
`NuFaturouAtraso` int(11) DEFAULT NULL,
`NuFaturouFinan` int(11) DEFAULT NULL,
`NuMudStatus1` int(11) DEFAULT NULL,
`NuMudStatus2` int(11) DEFAULT NULL,
`NuAumentoSdoRefinM3` int(11) DEFAULT NULL,
`NuAumentoSdoRefinM6` int(11) DEFAULT NULL,
`NuAumentoSdoRefinM9` int(11) DEFAULT NULL,
KEY `IDX01` (`NuCpfCnpj`,`CdProduto`,`TpCartao`,`NuConta`,`DtCorte`),
KEY `Idx100` (`DtCorte`),
KEY `Idx101` (`NuCpfCnpj`),
KEY `Idx102` (`NuConta`),
KEY `Idx103` (`CdProduto`),
KEY `Idx104` (`TpCartao`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Segue Query
Drop Table If Exists TbBehavior_Resume;
Create Temporary Table TbBehavior_Resume(
Select
Concat(a.NuCpfCnpj, a.CdProduto, a.TpCartao, a.NuConta, a.DtCorte) Chave,
a.NuCpfCnpj,
a.CdProduto,
a.TpCartao,
a.NuConta,
a.DtCorte,
a.StCartaoM0,
a.StCartaoM1,
a.StCartaoM2,
a.StCartaoM3,
a.StCartaoM4,
a.StCartaoM5,
a.StCartaoM6,
a.StContaM0,
a.StContaM1,
a.StContaM2,
a.StContaM3,
a.StContaM4,
a.StContaM5,
a.StContaM6,
a.DtCorteM0,
a.DtCorteM1,
a.DtCorteM2,
a.DtCorteM3,
a.DtCorteM4,
a.DtCorteM5,
a.DtCorteM6,
a.DtAberturaCta,
a.DtNascimento,
a.CdProfissao,
a.QtdAdicionais,
a.FlagSeguroPerdaRoubo,
a.DtPrimeiraTransacao,
a.DtPrimeiroDesblq,
a.CdGrupoRelacionamento,
a.GrpRelacionamento,
a.DtEnquadramento,
a.SaldoFaturaM0,
a.SaldoFaturaM1,
a.SaldoFaturaM2,
a.SaldoFaturaM3,
a.SaldoFaturaM4,
a.SaldoFaturaM5,
a.SaldoFaturaM6,
a.VlrJuroMultaM0,
a.VlrJuroMultaM1,
a.VlrJuroMultaM2,
a.VlrJuroMultaM3,
a.VlrJuroMultaM4,
a.VlrJuroMultaM5,
a.VlrJuroMultaM6,
a.VlrJurosFinanciamentoM0,
a.VlrJurosFinanciamentoM1,
a.VlrJurosFinanciamentoM2,
a.VlrJurosFinanciamentoM3,
a.VlrJurosFinanciamentoM4,
a.VlrJurosFinanciamentoM5,
a.VlrJurosFinanciamentoM6,
a.DiasAtrasoM0,
a.DiasAtrasoM1,
a.DiasAtrasoM2,
a.DiasAtrasoM3,
a.DiasAtrasoM4,
a.DiasAtrasoM5,
a.DiasAtrasoM6,
a.DiasAtrasoCorteM0,
a.DiasAtrasoCorteM1,
a.DiasAtrasoCorteM2,
a.DiasAtrasoCorteM3,
a.DiasAtrasoCorteM4,
a.DiasAtrasoCorteM5,
a.DiasAtrasoCorteM6,
a.VlrSaqueCashM0,
a.VlrSaqueCashM1,
a.VlrSaqueCashM2,
a.VlrSaqueCashM3,
a.VlrSaqueCashM4,
a.VlrSaqueCashM5,
a.VlrSaqueCashM6,
a.VlrPgtoCorteM0,
a.VlrPgtoCorteM1,
a.VlrPgtoCorteM2,
a.VlrPgtoCorteM3,
a.VlrPgtoCorteM4,
a.VlrPgtoCorteM5,
a.VlrPgtoCorteM6,
a.VlrComprasM0,
a.VlrComprasM1,
a.VlrComprasM2,
a.VlrComprasM3,
a.VlrComprasM4,
a.VlrComprasM5,
a.VlrComprasM6,
a.QtdComprasCorteM0,
a.QtdComprasCorteM1,
a.QtdComprasCorteM2,
a.QtdComprasCorteM3,
a.QtdComprasCorteM4,
a.QtdComprasCorteM5,
a.QtdComprasCorteM6,
a.LimiteCorteM0,
a.LimiteCorteM1,
a.LimiteCorteM2,
a.LimiteCorteM3,
a.LimiteCorteM4,
a.LimiteCorteM5,
a.LimiteCorteM6,
a.SldParVencCortM0,
a.SldParVencCortM1,
a.SldParVencCortM2,
a.SldParVencCortM3,
a.SldParVencCortM4,
a.SldParVencCortM5,
a.SldParVencCortM6,
a.VlrAnuidadeCorteM0,
a.VlrAnuidadeCorteM1,
a.VlrAnuidadeCorteM2,
a.VlrAnuidadeCorteM3,
a.VlrAnuidadeCorteM4,
a.VlrAnuidadeCorteM5,
a.VlrAnuidadeCorteM6,
a.IndicativoFaturamentoM0,
a.IndicativoFaturamentoM1,
a.IndicativoFaturamentoM2,
a.IndicativoFaturamentoM3,
a.IndicativoFaturamentoM4,
a.IndicativoFaturamentoM5,
a.IndicativoFaturamentoM6,
a.DtPgtoCorteM0,
a.DtPgtoCorteM1,
a.DtPgtoCorteM2,
a.DtPgtoCorteM3,
a.DtPgtoCorteM4,
a.DtPgtoCorteM5,
a.DtPgtoCorteM6,
a.DtVencCorteM0,
a.DtVencCorteM1,
a.DtVencCorteM2,
a.DtVencCorteM3,
a.DtVencCorteM4,
a.DtVencCorteM5,
a.DtVencCorteM6,
a.VlrPgtoMinFaturaCorteM0,
a.VlrPgtoMinFaturaCorteM1,
a.VlrPgtoMinFaturaCorteM2,
a.VlrPgtoMinFaturaCorteM3,
a.VlrPgtoMinFaturaCorteM4,
a.VlrPgtoMinFaturaCorteM5,
a.VlrPgtoMinFaturaCorteM6,
a.VlrLimiteSaqueCorteM0,
a.VlrLimiteSaqueCorteM1,
a.VlrLimiteSaqueCorteM2,
a.VlrLimiteSaqueCorteM3,
a.VlrLimiteSaqueCorteM4,
a.VlrLimiteSaqueCorteM5,
a.VlrLimiteSaqueCorteM6,
a.SldDispCorteM0,
a.SldDispCorteM1,
a.SldDispCorteM2,
a.SldDispCorteM3,
a.SldDispCorteM4,
a.SldDispCorteM5,
a.SldDispCorteM6,
(CASE
When a.VlrJurosFinanciamentoM0 > 0 or a.VlrJurosFinanciamentoM1 > 0 or a.VlrJurosFinanciamentoM2 > 0 or a.VlrJurosFinanciamentoM3 > 0 or a.VlrJurosFinanciamentoM4 > 0 or a.VlrJurosFinanciamentoM5 > 0 THEN 'S'
Else 'N'
END) Financiou6
From Mis.TbBehavior a
Where DtCorte in ('200807','200808','200809','200810','200811','200812','200901','200902','200903','200904','200905','200906','200907','200908','200909','200910','200911','200912')
);
Create Index IdxTempBs On TbBehavior_Resume (Chave);
Describe TbBehavior_Resume
Drop table If Exists TbCalculadas_Resume;
Create Temporary Table TbCalculadas_Resume(
Select
Concat(b.NuCpfCnpj, b.CdProduto, b.TpCartao, b.NuConta, b.DtCorte) Chave,
b.NuCpfCnpj as NuCpfCnpj_s,
b.CdProduto as CdProduto_s,
b.TpCartao as TpCartao_s,
b.NuConta as NuConta_s,
b.DtCorte as DtCorte_s,
b.IdadeTitular,
b.LogTitular,
b.Cep2,
b.Cep6,
b.IdadeConta,
b.LogConta,
b.NuFaturasM0,
b.NuFaturasM3,
b.NuFaturasM6,
b.NuMesesComprasM0,
b.NuMesesComprasM3,
b.NuMesesComprasM6,
b.NuMesesSaldoM0,
b.NuMesesSaldoM3,
b.NuMesesSaldoM6,
b.UtilizacaoM3,
b.UtilizacaoM6,
b.NuBucket1M3,
b.NuBucket1M6,
b.NuBucket2M3,
b.NuBucket2M6,
b.CashM0,
b.CashM3,
b.CashM6,
b.PercCashM0,
b.PercCashM3,
b.PercCashM6,
b.SaqueM0,
b.SaqueM3,
b.SaqueM6,
b.AtrasoM0,
b.AtrasoM3,
b.AtrasoM6,
b.TempUtilizacao,
b.NuReduSaldoM3,
b.NuReduSaldoM6,
b.NuAumenSaldoM3,
b.NuAumenSaldoM6,
b.NuPagtoM3,
b.NuPagtoM6,
b.NuSemPgtoM3,
b.NuSemPgtoM6,
b.PercSaldoPgtoM0,
b.PercSaldoPgtoM3,
b.PercSaldoPgtoM6,
b.NuFinaciamentoM0,
b.NuFinaciamentoM3,
b.NuFinaciamentoM6,
b.PercenComprasM0,
b.PercenComprasM3,
b.PercenComprasM6,
b.PercenFinanciadoM0,
b.PercenFinanciadoM3,
b.PercenFinanciadoM6,
b.PercenLimiteM3,
b.PercenLimiteM6,
b.NuComprasM0,
b.NuComprasM3,
b.NuComprasM6,
b.NuOverlimitM0,
b.NuOverlimitM3,
b.NuOverlimitM6,
b.NuPagtoTotalM0,
b.NuPagtoTotalM3,
b.NuPagtoTotalM6,
b.PercSaldoM3,
b.PercSaldoM6,
b.NuAumentoRefinM3,
b.NuAumentoRefinM6,
b.NuDemiRefinM3,
b.NuDemiRefinM6,
b.NuSemMudanRefinM3,
b.NuSemMudanRefinM6,
b.PercMaiorRefinM3,
b.PercMaiorRefinM6,
b.UltimaUtilizacao,
b.AtrasoCorrenteM3,
b.AtrasoCorrenteM6,
b.CrescAtrasoM3,
b.CrescAtrasoM6,
b.DiminAtrasoM3,
b.DiminAtrasoM6,
b.SemMudancaAtrasoM3,
b.SemMudancaAtrasoM6,
b.NuMedioCompras,
b.SaldoMedioM3,
b.SaldoMedioM6,
b.NuFaturouCorr,
b.NuFaturouAtraso,
b.NuFaturouFinan,
b.NuMudStatus1,
b.NuMudStatus2,
b.NuAumentoSdoRefinM3,
b.NuAumentoSdoRefinM6
From mis.tbvariaveiscalculadas b
Where b.DtCorte in ('200807','200808','200809','200810','200811','200812','200901','200902','200903','200904','200905','200906','200907','200908','200909','200910','200911','200912')
);
Alter Table TbCalculadas_Resume Modify Chave Varchar(50) Not Null;
Alter Table TbBehavior_Resume Modify Chave Varchar(50) Not Null;
Create Index IdxTempCalcula On TbCalculadas_Resume (Chave);
ALTER TABLE TbCalculadas_Resume
CHANGE Chave ChaveS Varchar(50) not null;
/*
Show Columns From TbCalculadas_Resume;
Show Columns From TbBehavior_Resume;
Show Index From TbCalculadas_Resume;
Show Index From TbBehavior_Resume;
*/
Create Table Modelagem.TbNovaModelo1 (
explain Select *
From TbBehavior_Resume a Force Index (IdxTempBs)
STRAIGHT_JOIN TbCalculadas_Resume b
On a.Chave = b.Chaves
);