none
Query SQL RRS feed

  • Pergunta

  • Alguém pode me ajudar?

    Tenho o sql abaixo e ela trava. Já tentei de inúmeras maneiras. Não sei se estou fazendo isso certo, mas tenho que pesquisar se o código ncm está dentro de algum dos ranges.

    Não sei se é possível usar tantos betweens como estou fazendo?

    Agradeço desde já, Bjos

    SELECT  bethadba.efsaidas.codi_emp, 
              bethadba.efsaidas.codi_sai, 
              bethadba.efsaidas.dsai_sai,
              bethadba.efsaidas.nume_sai,
              bethadba.efsaidas.codi_cli,
              bethadba.efsaidas.I_REDUCAO, 
              bethadba.efmvspro.vpro_msp,   
              bethadba.efmvspro.vdes_msp,
              bethadba.efmvspro.vfre_msp,
              bethadba.efmvspro.vseg_msp,
              bethadba.efmvspro.vdesace_msp, 
              bethadba.efmvspro.cfop_msp, 
              bethadba.efprodutos.cncm_pdi,
              bethadba.geempre.razao_emp, 
              bethadba.geempre.cgce_emp
              
               

        FROM  bethadba.efsaidas,
              bethadba.efmvspro,
              bethadba.efprodutos,
              bethadba.geempre

       WHERE 
             
             bethadba.efsaidas.codi_emp = 1219 AND 
             bethadba.geempre.codi_emp = 1219 AND
             bethadba.efsaidas.dsai_sai BETWEEN YMD(2012,08,01) AND YMD(2012,08,01) AND
             bethadba.efmvspro.codi_emp =bethadba.efsaidas.codi_emp AND
             bethadba.efmvspro.codi_sai = bethadba.efsaidas.codi_sai AND 
             bethadba.efprodutos.codi_pdi =bethadba.efmvspro.codi_pdi AND
             bethadba.efprodutos.codi_emp = bethadba.efsaidas.codi_emp AND   
             bethadba.efmvspro.cfop_msp IN (5101,5103,5105,5109,5111,5113,5118,5122,5124,5125,5401,5402,5501,5651,5652,5653,5922,6101,6103,6105,6107,6109,6111,6113,6118,6122,6124,6125,6401,6402,6501,6651,6652,6653,6922,7101,7105,7124,7127,7651)AND
             
             bethadba.efprodutos.cncm_pdi NOT IN (65061000,84091000,84221110,84231000,84512100,84529020,85115090,85121000,85461000,85472010,87029010,84521000)  AND

             
             bethadba.efprodutos.cncm_pdi IN (30059090,38151210,38190000,40091100,40091210,40091290,40093100,40093210,40093290,40094210,40094290,40103100,40103200,40103300,40103400,40103500,40103600,40103900,40161010,40169100,40169300,40169990,42021100,42021220,42022100,42022220,42023100,42023200,42029100,42029200,42050000,44219000,45049000,48185000,50040000,50050000,50060000,51040000,51100000,52030000,53110000,68079000,68128000,68129010,68129100,68129910,68131010,68131090,68132000,68138110,68138190,68138910,68138990,68139010,68139090,69091930,70071100,70072100,70091000,73030000,73081000,73082000,73090010,73090090,73101090,73102910,73102990,73110000,73151100,73151210,73151290,73151900,73152000,73158100,73158200,73158900,73159000,73160000,73201000,73202010,73202090,73209000,73269090,74199990,76129090,82054000,82073000,83012000,83023000,83081000,83082000,83100000,84671110,84671190,84671900,84672991,84672993,84678100,84678900,84679100,84679200,84679900,84681000,84682000,84688010,84688090,84689010,84689020,84689090,84690010,84709010,84709090,84718000,84719019,84719090,84721000,84723090,84729010,84729029,84729030,84729040,84729091,84729099,84731010,84781010,84781090,84789000,84011000,84012000,84014000,84141000,84142000,84143011,84143019,84143091,84143099,84144010,84144020,84144090,84145910,84145990,84148011,84148012,84148013,84148019,84148021,84148022,84148029,84148031,84148032,84148033,84148038,84148039,84148090,84149010,84149020,84149031,84149032,84149033,84149034,84149039,84151090,84152010,84152090,84158110,84158190,84158210,84158290,84158300,84159000,84185010,84185090,84186100,84186910,84186920,84186931,84186932,84186940,84186991,84186999,84189900,84219920,84211110,84211190,84211290,84211910,84211990,84212100,84212200,84212300,84212920,84212930,84212990,84213100,84213910,84213920,84213930,84213990,84219191,84219199,84219910,84219991,84219999,84431110,84431190,84431200,84431310,84431321,84431329,84431390,84431400,84431500,84431600,84431710,84431790,84431910,84431990,84433910,84433921,84433928,84433929,84433930,84433990,84439110,84439191,84439192,84439199,84811000,84812010,84812011,84812019,84812090,84813000,84814000,84818021,84818029,84818039,84818092,84818093,84818094,84818095,84818096,84818097,84818099,84819090,84823000,84825090,84828000,84829120,84829130,84829190,84829911,84829919,85030010,85030090,85042100,85042200,85042300,85043111,85043119,85043211,85043219,85043221,85043300,85043400,85044022,85044030,85044050,85044090,85051910,85052090,85059010,85059080,85059090,85071000,85071010,85071090,85072010,85072090,85079010,85079090,85086000,85087000,85141010,85141090,85142011,85142019,85142020,85143011,85143019,85143021,85143029,85143090,85144000,85149000,85151100,85151900,85152100,85152900,85153110,85153190,85153900,85158010,85158090,85159000,85161000,85167100,85167920,85167990,85168010,85169000,85171891,85171899,85176130,85176212,85176221,85176222,85176223,85176224,85176229,85176232,85176239,85176241,85176248,85176251,85176254,85176255,85176259,85176262,85176272,85176277,85176278,85176279,85176294,85176299,85176900,85177010,85182100,85182200,85182990,85269200,85272110,85272190,85272900,85272990,85287111,85311090,85321000,85322990,85352100,85353017,85353018,85353027,85353028,85361000,85362000,85363000,85364100,85364900,85365090,85366100,85366910,85366990,85369010,85369040,85369090,85371020,85371090,85372090,85381000,85389090,85392910,85392990,85408990,85431000,85432000,85433000,85437013,85437039,85437040,85437099,85439090,85443000,85444200,85489090,86011000,86071919,87011000,87013000,87019010,87019090,87041010,87041090,87051010,87051090,87052000,87053000,87054000,87059010,87059090,87060020,87071000,87079010,87079090,87081000,87082100,87082911,87082912,87082913,87082914,87082919,87082991,87082992,87082993,87082994,87082995,87082996,87082999,87083011,87083019,87083090,87083110,87083190,87083900,87084011,87084019,87084080,87084090,87085011,87085012,87085019,87085080,87085090,87085091,87085099,87086010,87086090,87087010,87087090,87088000,87089100,87089200,87089300,87089411,87089412,87089413,87089481,87089482,87089483,87089490,87089491,87089492,87089493,87089510,87089521,87089522,87089529,87089910,87089990,87091100,87091900,87099000,87100000,87141000,87141900,87149490,87149990,87162000,87163100,87163900,88040000,90058000,90059090,90061010,90061090,90072090,90072091,90072099,90079200,90085000,90089000,90101010,90101020,90101090,90109010,90111000,90118010,90118090,90119090,90131090,90151000,90152010,90152090,90153000,90154000,90158010,90158090,90159010,90159090,90160010,90160090,90171010,90171090,90173010,90173020,90173090,90179010,90179090,90189091,90191000,90221910,90221991,90221999,90222910,90222990,90241010,90241020,90241090,90248011,90248019,90248021,90248029,90248090,90249000,90251190,90251910,90251990,90258000,90259010,90259090,90261019,90261021,90261029,90262010,90262090,90268000,90269010,90269020,90269090,90271000,90272011,90272012,90272019,90272021,90272029,90273011,90273019,90273020,90275010,90275020,90275030,90275040,90275050,90275090,90278011,90278012,90278013,90278014,90278020,90278030,90278091,90278099,90279010,90279091,90279093,90279099,90281011,90281019,90281090,90282010,90282020,90283011,90283019,90283021,90283029,90283031,90283039,90283090,90289010,90289090,90289090,90291010,90292010,90299010,90303321,90303921,90303990,90304030,90304090,90308490,90308990,90309090,90311000,90312010,90312090,90314100,90314910,90314920,90314990,90318011,90318012,90318020,90318030,90318040,90318050,90318060,90318091,90318099,90319010,90319090,90321010,90321090,90322000,90328100,90328911,90329010,90329099,90330000,91040000,91070010,91091000,94012000,94018000,94049000,94051093,94051099,94052000,94059100,94060010,94060092,95066200,95069100,96138000) OR
             
              bethadba.efprodutos.cncm_pdi BETWEEN (02030000) AND (02039999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (02101000) AND (02101999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39150000) AND (39159999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39160000) AND (39169999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39170000) AND (39179999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39180000) AND (39189999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39190000) AND (39199999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39200000) AND (39209999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39210000) AND (39219999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39220000) AND (39229999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39230000) AND (39239999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39240000) AND (39249999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39250000) AND (39259999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (39260000) AND (39269999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (40150000) AND (40159999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (41040000) AND (41049999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (41050000) AND (41059999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (41060000) AND (41069999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (41070000) AND (41079999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (41140000) AND (41149999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (42030000) AND (42039999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (43030000) AND (43039999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (50070000) AND (50079999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (51050000) AND (51059999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (51060000) AND (51069999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (51070000) AND (51079999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (51080000) AND (51089999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (51090000) AND (51099999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (51110000) AND (51119999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (51120000) AND (51129999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (51130000) AND (51130099) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (52040000) AND (52049999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (52050000) AND (52059999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (52060000) AND (52069999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (52070000) AND (52079999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (52080000) AND (52089999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (52090000) AND (52099999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (52100000) AND (52109999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (52110000) AND (52119999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (52120000) AND (52129999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (53060000) AND (53069999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (53070000) AND (53079999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (53080000) AND (53089999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (53090000) AND (53099999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (53100000) AND (53109999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (54000000) AND (54999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (55000000) AND (55999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (56000000) AND (56999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (57000000) AND (57999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (58000000) AND (58999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (59000000) AND (59999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (60000000) AND (60999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (61000000) AND (61999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (62000000) AND (62999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (63000000) AND (63999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (64000000) AND (64999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (65000000) AND (65999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84020000) AND (84029999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84030000) AND (84039999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84040000) AND (84049999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84050000) AND (84059999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84060000) AND (84069999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84070000) AND (84079999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84080000) AND (84089999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84090000) AND (84999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84100000) AND (84109999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84110000) AND (84119999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84120000) AND (84129999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84130000) AND (84139999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84160000) AND (84169999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84170000) AND (84179999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84190000) AND (84199999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84200000) AND (84209999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84220000) AND (84229999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84230000) AND (84239999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84240000) AND (84249999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84250000) AND (84259999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84260000) AND (84269999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84270000) AND (84279999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84280000) AND (84289999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84290000) AND (84299999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84300000) AND (84309999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84310000) AND (84319999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84320000) AND (84329999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84330000) AND (84339999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84340000) AND (84349999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84350000) AND (84359999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84360000) AND (84369999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84370000) AND (84379999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84380000) AND (84389999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84390000) AND (84399999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84400000) AND (84409999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84410000) AND (84419999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84420000) AND (84429999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84440000) AND (84449999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84450000) AND (84459999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84460000) AND (84469999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84470000) AND (84479999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84480000) AND (84489999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84490000) AND (84499999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84502000) AND (84502099) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84510000) AND (84519999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84510000) AND (84519999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84530000) AND (84539999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84540000) AND (84549999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84550000) AND (84559999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84560000) AND (84569999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84570000) AND (84579999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84580000) AND (84589999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84590000) AND (84599999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84600000) AND (84609999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84610000) AND (84619999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84620000) AND (84629999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84630000) AND (84639999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84640000) AND (84649999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84650000) AND (84659999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84660000) AND (84669999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84740000) AND (84749999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84750000) AND (84759999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84760000) AND (84769999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84770000) AND (84779999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84790000) AND (84799999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84800000) AND (84809999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84830000) AND (84839999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84831010) AND (84831019) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84840000) AND (84849999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84860000) AND (84869999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (84870000) AND (84879999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (85010000) AND (85019999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (85020000) AND (85029999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (85110000) AND (85119999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (85120000) AND (85129999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (85130000) AND (85139999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (85410000) AND (85419999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (85460000) AND (85469999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (85470000) AND (85479999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (87020000) AND (87029999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (87070000) AND (87079999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (88020000) AND (88029999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (88030000) AND (88039999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (89000000) AND (89999999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (90328920) AND (90328929) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (90328980) AND (90328989) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (94013000) AND (94013099) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (94014000) AND (94014099) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (94015000) AND (94015999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (94016000) AND (94016999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (94017000) AND (94017999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (94019000) AND (94019999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (94020000) AND (94029999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (94030000) AND (94039999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (94042000) AND (94042900) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (96060000) AND (96069999) OR
              bethadba.efprodutos.cncm_pdi BETWEEN (96070000) AND (96079999)
              

    terça-feira, 9 de outubro de 2012 13:22

Respostas

  • Bom dia Flavia, no seu campo cncm_pdi ha algum indice ? voce ja tentou dividr a query em partes ? tente fazer desta maneira :

    Rode o primeiro select, depois a criação do indice na temporaria e depois o ultimo select.

    SELECT  bethadba.efsaidas.codi_emp, 
               bethadba.efsaidas.codi_sai, 
               bethadba.efsaidas.dsai_sai,
               bethadba.efsaidas.nume_sai,
               bethadba.efsaidas.codi_cli,
               bethadba.efsaidas.I_REDUCAO, 
               bethadba.efmvspro.vpro_msp,   
               bethadba.efmvspro.vdes_msp,
               bethadba.efmvspro.vfre_msp,
               bethadba.efmvspro.vseg_msp,
               bethadba.efmvspro.vdesace_msp, 
               bethadba.efmvspro.cfop_msp, 
               bethadba.efprodutos.cncm_pdi,
               bethadba.geempre.razao_emp, 
               bethadba.geempre.cgce_emp
    into #Temp_AUX
        FROM  bethadba.efsaidas,
               bethadba.efmvspro,
               bethadba.efprodutos,
               bethadba.geempre
       WHERE 
              bethadba.efsaidas.codi_emp = 1219 AND 
              bethadba.geempre.codi_emp = 1219 AND
              bethadba.efsaidas.dsai_sai BETWEEN YMD(2012,08,01) AND YMD(2012,08,01) AND
              bethadba.efmvspro.codi_emp =bethadba.efsaidas.codi_emp AND
              bethadba.efmvspro.codi_sai = bethadba.efsaidas.codi_sai AND 
              bethadba.efprodutos.codi_pdi =bethadba.efmvspro.codi_pdi AND
              bethadba.efprodutos.codi_emp = bethadba.efsaidas.codi_emp AND   
              bethadba.efmvspro.cfop_msp IN (5101,5103,5105,5109,5111,5113,5118,5122,5124,5125,5401,5402,5501,5651,5652,5653,5922,6101,6103,6105,6107,6109,6111,6113,6118,6122,6124,6125,6401,6402,6501,6651,6652,6653,6922,7101,7105,7124,7127,7651)AND
            
    Create clustered index IX_PDI on   #Temp_AUX (cncm_pdi)
    
    select 
    	* 
    		from #Temp_AUX
    where 
              cncm_pdi NOT IN (65061000,84091000,84221110,84231000,84512100,84529020,85115090,85121000,85461000,85472010,87029010,84521000)  AND
     
             
              cncm_pdi IN (30059090,38151210,38190000,40091100,40091210,40091290,40093100,40093210,40093290,40094210,40094290,40103100,40103200,40103300,40103400,40103500,40103600,40103900,40161010,40169100,40169300,40169990,42021100,42021220,42022100,42022220,42023100,42023200,42029100,42029200,42050000,44219000,45049000,48185000,50040000,50050000,50060000,51040000,51100000,52030000,53110000,68079000,68128000,68129010,68129100,68129910,68131010,68131090,68132000,68138110,68138190,68138910,68138990,68139010,68139090,69091930,70071100,70072100,70091000,73030000,73081000,73082000,73090010,73090090,73101090,73102910,73102990,73110000,73151100,73151210,73151290,73151900,73152000,73158100,73158200,73158900,73159000,73160000,73201000,73202010,73202090,73209000,73269090,74199990,76129090,82054000,82073000,83012000,83023000,83081000,83082000,83100000,84671110,84671190,84671900,84672991,84672993,84678100,84678900,84679100,84679200,84679900,84681000,84682000,84688010,84688090,84689010,84689020,84689090,84690010,84709010,84709090,84718000,84719019,84719090,84721000,84723090,84729010,84729029,84729030,84729040,84729091,84729099,84731010,84781010,84781090,84789000,84011000,84012000,84014000,84141000,84142000,84143011,84143019,84143091,84143099,84144010,84144020,84144090,84145910,84145990,84148011,84148012,84148013,84148019,84148021,84148022,84148029,84148031,84148032,84148033,84148038,84148039,84148090,84149010,84149020,84149031,84149032,84149033,84149034,84149039,84151090,84152010,84152090,84158110,84158190,84158210,84158290,84158300,84159000,84185010,84185090,84186100,84186910,84186920,84186931,84186932,84186940,84186991,84186999,84189900,84219920,84211110,84211190,84211290,84211910,84211990,84212100,84212200,84212300,84212920,84212930,84212990,84213100,84213910,84213920,84213930,84213990,84219191,84219199,84219910,84219991,84219999,84431110,84431190,84431200,84431310,84431321,84431329,84431390,84431400,84431500,84431600,84431710,84431790,84431910,84431990,84433910,84433921,84433928,84433929,84433930,84433990,84439110,84439191,84439192,84439199,84811000,84812010,84812011,84812019,84812090,84813000,84814000,84818021,84818029,84818039,84818092,84818093,84818094,84818095,84818096,84818097,84818099,84819090,84823000,84825090,84828000,84829120,84829130,84829190,84829911,84829919,85030010,85030090,85042100,85042200,85042300,85043111,85043119,85043211,85043219,85043221,85043300,85043400,85044022,85044030,85044050,85044090,85051910,85052090,85059010,85059080,85059090,85071000,85071010,85071090,85072010,85072090,85079010,85079090,85086000,85087000,85141010,85141090,85142011,85142019,85142020,85143011,85143019,85143021,85143029,85143090,85144000,85149000,85151100,85151900,85152100,85152900,85153110,85153190,85153900,85158010,85158090,85159000,85161000,85167100,85167920,85167990,85168010,85169000,85171891,85171899,85176130,85176212,85176221,85176222,85176223,85176224,85176229,85176232,85176239,85176241,85176248,85176251,85176254,85176255,85176259,85176262,85176272,85176277,85176278,85176279,85176294,85176299,85176900,85177010,85182100,85182200,85182990,85269200,85272110,85272190,85272900,85272990,85287111,85311090,85321000,85322990,85352100,85353017,85353018,85353027,85353028,85361000,85362000,85363000,85364100,85364900,85365090,85366100,85366910,85366990,85369010,85369040,85369090,85371020,85371090,85372090,85381000,85389090,85392910,85392990,85408990,85431000,85432000,85433000,85437013,85437039,85437040,85437099,85439090,85443000,85444200,85489090,86011000,86071919,87011000,87013000,87019010,87019090,87041010,87041090,87051010,87051090,87052000,87053000,87054000,87059010,87059090,87060020,87071000,87079010,87079090,87081000,87082100,87082911,87082912,87082913,87082914,87082919,87082991,87082992,87082993,87082994,87082995,87082996,87082999,87083011,87083019,87083090,87083110,87083190,87083900,87084011,87084019,87084080,87084090,87085011,87085012,87085019,87085080,87085090,87085091,87085099,87086010,87086090,87087010,87087090,87088000,87089100,87089200,87089300,87089411,87089412,87089413,87089481,87089482,87089483,87089490,87089491,87089492,87089493,87089510,87089521,87089522,87089529,87089910,87089990,87091100,87091900,87099000,87100000,87141000,87141900,87149490,87149990,87162000,87163100,87163900,88040000,90058000,90059090,90061010,90061090,90072090,90072091,90072099,90079200,90085000,90089000,90101010,90101020,90101090,90109010,90111000,90118010,90118090,90119090,90131090,90151000,90152010,90152090,90153000,90154000,90158010,90158090,90159010,90159090,90160010,90160090,90171010,90171090,90173010,90173020,90173090,90179010,90179090,90189091,90191000,90221910,90221991,90221999,90222910,90222990,90241010,90241020,90241090,90248011,90248019,90248021,90248029,90248090,90249000,90251190,90251910,90251990,90258000,90259010,90259090,90261019,90261021,90261029,90262010,90262090,90268000,90269010,90269020,90269090,90271000,90272011,90272012,90272019,90272021,90272029,90273011,90273019,90273020,90275010,90275020,90275030,90275040,90275050,90275090,90278011,90278012,90278013,90278014,90278020,90278030,90278091,90278099,90279010,90279091,90279093,90279099,90281011,90281019,90281090,90282010,90282020,90283011,90283019,90283021,90283029,90283031,90283039,90283090,90289010,90289090,90289090,90291010,90292010,90299010,90303321,90303921,90303990,90304030,90304090,90308490,90308990,90309090,90311000,90312010,90312090,90314100,90314910,90314920,90314990,90318011,90318012,90318020,90318030,90318040,90318050,90318060,90318091,90318099,90319010,90319090,90321010,90321090,90322000,90328100,90328911,90329010,90329099,90330000,91040000,91070010,91091000,94012000,94018000,94049000,94051093,94051099,94052000,94059100,94060010,94060092,95066200,95069100,96138000) OR
              
               cncm_pdi BETWEEN (02030000) AND (02039999) OR
               cncm_pdi BETWEEN (02101000) AND (02101999) OR
               cncm_pdi BETWEEN (39150000) AND (39159999) OR
               cncm_pdi BETWEEN (39160000) AND (39169999) OR
               cncm_pdi BETWEEN (39170000) AND (39179999) OR
               cncm_pdi BETWEEN (39180000) AND (39189999) OR
               cncm_pdi BETWEEN (39190000) AND (39199999) OR
               cncm_pdi BETWEEN (39200000) AND (39209999) OR
               cncm_pdi BETWEEN (39210000) AND (39219999) OR
               cncm_pdi BETWEEN (39220000) AND (39229999) OR
               cncm_pdi BETWEEN (39230000) AND (39239999) OR
               cncm_pdi BETWEEN (39240000) AND (39249999) OR
               cncm_pdi BETWEEN (39250000) AND (39259999) OR
               cncm_pdi BETWEEN (39260000) AND (39269999) OR
               cncm_pdi BETWEEN (40150000) AND (40159999) OR
               cncm_pdi BETWEEN (41040000) AND (41049999) OR
               cncm_pdi BETWEEN (41050000) AND (41059999) OR
               cncm_pdi BETWEEN (41060000) AND (41069999) OR
               cncm_pdi BETWEEN (41070000) AND (41079999) OR
               cncm_pdi BETWEEN (41140000) AND (41149999) OR
               cncm_pdi BETWEEN (42030000) AND (42039999) OR
               cncm_pdi BETWEEN (43030000) AND (43039999) OR
               cncm_pdi BETWEEN (50070000) AND (50079999) OR
               cncm_pdi BETWEEN (51050000) AND (51059999) OR
               cncm_pdi BETWEEN (51060000) AND (51069999) OR
               cncm_pdi BETWEEN (51070000) AND (51079999) OR
               cncm_pdi BETWEEN (51080000) AND (51089999) OR
               cncm_pdi BETWEEN (51090000) AND (51099999) OR
               cncm_pdi BETWEEN (51110000) AND (51119999) OR
               cncm_pdi BETWEEN (51120000) AND (51129999) OR
               cncm_pdi BETWEEN (51130000) AND (51130099) OR
               cncm_pdi BETWEEN (52040000) AND (52049999) OR
               cncm_pdi BETWEEN (52050000) AND (52059999) OR
               cncm_pdi BETWEEN (52060000) AND (52069999) OR
               cncm_pdi BETWEEN (52070000) AND (52079999) OR
               cncm_pdi BETWEEN (52080000) AND (52089999) OR
               cncm_pdi BETWEEN (52090000) AND (52099999) OR
               cncm_pdi BETWEEN (52100000) AND (52109999) OR
               cncm_pdi BETWEEN (52110000) AND (52119999) OR
               cncm_pdi BETWEEN (52120000) AND (52129999) OR
               cncm_pdi BETWEEN (53060000) AND (53069999) OR
               cncm_pdi BETWEEN (53070000) AND (53079999) OR
               cncm_pdi BETWEEN (53080000) AND (53089999) OR
               cncm_pdi BETWEEN (53090000) AND (53099999) OR
               cncm_pdi BETWEEN (53100000) AND (53109999) OR
               cncm_pdi BETWEEN (54000000) AND (54999999) OR
               cncm_pdi BETWEEN (55000000) AND (55999999) OR
               cncm_pdi BETWEEN (56000000) AND (56999999) OR
               cncm_pdi BETWEEN (57000000) AND (57999999) OR
               cncm_pdi BETWEEN (58000000) AND (58999999) OR
               cncm_pdi BETWEEN (59000000) AND (59999999) OR
               cncm_pdi BETWEEN (60000000) AND (60999999) OR
               cncm_pdi BETWEEN (61000000) AND (61999999) OR
               cncm_pdi BETWEEN (62000000) AND (62999999) OR
               cncm_pdi BETWEEN (63000000) AND (63999999) OR
               cncm_pdi BETWEEN (64000000) AND (64999999) OR
               cncm_pdi BETWEEN (65000000) AND (65999999) OR
               cncm_pdi BETWEEN (84020000) AND (84029999) OR
               cncm_pdi BETWEEN (84030000) AND (84039999) OR
               cncm_pdi BETWEEN (84040000) AND (84049999) OR
               cncm_pdi BETWEEN (84050000) AND (84059999) OR
               cncm_pdi BETWEEN (84060000) AND (84069999) OR
               cncm_pdi BETWEEN (84070000) AND (84079999) OR
               cncm_pdi BETWEEN (84080000) AND (84089999) OR
               cncm_pdi BETWEEN (84090000) AND (84999999) OR
               cncm_pdi BETWEEN (84100000) AND (84109999) OR
               cncm_pdi BETWEEN (84110000) AND (84119999) OR
               cncm_pdi BETWEEN (84120000) AND (84129999) OR
               cncm_pdi BETWEEN (84130000) AND (84139999) OR
               cncm_pdi BETWEEN (84160000) AND (84169999) OR
               cncm_pdi BETWEEN (84170000) AND (84179999) OR
               cncm_pdi BETWEEN (84190000) AND (84199999) OR
               cncm_pdi BETWEEN (84200000) AND (84209999) OR
               cncm_pdi BETWEEN (84220000) AND (84229999) OR
               cncm_pdi BETWEEN (84230000) AND (84239999) OR
               cncm_pdi BETWEEN (84240000) AND (84249999) OR
               cncm_pdi BETWEEN (84250000) AND (84259999) OR
               cncm_pdi BETWEEN (84260000) AND (84269999) OR
               cncm_pdi BETWEEN (84270000) AND (84279999) OR
               cncm_pdi BETWEEN (84280000) AND (84289999) OR
               cncm_pdi BETWEEN (84290000) AND (84299999) OR
               cncm_pdi BETWEEN (84300000) AND (84309999) OR
               cncm_pdi BETWEEN (84310000) AND (84319999) OR
               cncm_pdi BETWEEN (84320000) AND (84329999) OR
               cncm_pdi BETWEEN (84330000) AND (84339999) OR
               cncm_pdi BETWEEN (84340000) AND (84349999) OR
               cncm_pdi BETWEEN (84350000) AND (84359999) OR
               cncm_pdi BETWEEN (84360000) AND (84369999) OR
               cncm_pdi BETWEEN (84370000) AND (84379999) OR
               cncm_pdi BETWEEN (84380000) AND (84389999) OR
               cncm_pdi BETWEEN (84390000) AND (84399999) OR
               cncm_pdi BETWEEN (84400000) AND (84409999) OR
               cncm_pdi BETWEEN (84410000) AND (84419999) OR
               cncm_pdi BETWEEN (84420000) AND (84429999) OR
               cncm_pdi BETWEEN (84440000) AND (84449999) OR
               cncm_pdi BETWEEN (84450000) AND (84459999) OR
               cncm_pdi BETWEEN (84460000) AND (84469999) OR
               cncm_pdi BETWEEN (84470000) AND (84479999) OR
               cncm_pdi BETWEEN (84480000) AND (84489999) OR
               cncm_pdi BETWEEN (84490000) AND (84499999) OR
               cncm_pdi BETWEEN (84502000) AND (84502099) OR
               cncm_pdi BETWEEN (84510000) AND (84519999) OR
               cncm_pdi BETWEEN (84510000) AND (84519999) OR
               cncm_pdi BETWEEN (84530000) AND (84539999) OR
               cncm_pdi BETWEEN (84540000) AND (84549999) OR
               cncm_pdi BETWEEN (84550000) AND (84559999) OR
               cncm_pdi BETWEEN (84560000) AND (84569999) OR
               cncm_pdi BETWEEN (84570000) AND (84579999) OR
               cncm_pdi BETWEEN (84580000) AND (84589999) OR
               cncm_pdi BETWEEN (84590000) AND (84599999) OR
               cncm_pdi BETWEEN (84600000) AND (84609999) OR
               cncm_pdi BETWEEN (84610000) AND (84619999) OR
               cncm_pdi BETWEEN (84620000) AND (84629999) OR
               cncm_pdi BETWEEN (84630000) AND (84639999) OR
               cncm_pdi BETWEEN (84640000) AND (84649999) OR
               cncm_pdi BETWEEN (84650000) AND (84659999) OR
               cncm_pdi BETWEEN (84660000) AND (84669999) OR
               cncm_pdi BETWEEN (84740000) AND (84749999) OR
               cncm_pdi BETWEEN (84750000) AND (84759999) OR
               cncm_pdi BETWEEN (84760000) AND (84769999) OR
               cncm_pdi BETWEEN (84770000) AND (84779999) OR
               cncm_pdi BETWEEN (84790000) AND (84799999) OR
               cncm_pdi BETWEEN (84800000) AND (84809999) OR
               cncm_pdi BETWEEN (84830000) AND (84839999) OR
               cncm_pdi BETWEEN (84831010) AND (84831019) OR
               cncm_pdi BETWEEN (84840000) AND (84849999) OR
               cncm_pdi BETWEEN (84860000) AND (84869999) OR
               cncm_pdi BETWEEN (84870000) AND (84879999) OR
               cncm_pdi BETWEEN (85010000) AND (85019999) OR
               cncm_pdi BETWEEN (85020000) AND (85029999) OR
               cncm_pdi BETWEEN (85110000) AND (85119999) OR
               cncm_pdi BETWEEN (85120000) AND (85129999) OR
               cncm_pdi BETWEEN (85130000) AND (85139999) OR
               cncm_pdi BETWEEN (85410000) AND (85419999) OR
               cncm_pdi BETWEEN (85460000) AND (85469999) OR
               cncm_pdi BETWEEN (85470000) AND (85479999) OR
               cncm_pdi BETWEEN (87020000) AND (87029999) OR
               cncm_pdi BETWEEN (87070000) AND (87079999) OR
               cncm_pdi BETWEEN (88020000) AND (88029999) OR
               cncm_pdi BETWEEN (88030000) AND (88039999) OR
               cncm_pdi BETWEEN (89000000) AND (89999999) OR
               cncm_pdi BETWEEN (90328920) AND (90328929) OR
               cncm_pdi BETWEEN (90328980) AND (90328989) OR
               cncm_pdi BETWEEN (94013000) AND (94013099) OR
               cncm_pdi BETWEEN (94014000) AND (94014099) OR
               cncm_pdi BETWEEN (94015000) AND (94015999) OR
               cncm_pdi BETWEEN (94016000) AND (94016999) OR
               cncm_pdi BETWEEN (94017000) AND (94017999) OR
               cncm_pdi BETWEEN (94019000) AND (94019999) OR
               cncm_pdi BETWEEN (94020000) AND (94029999) OR
               cncm_pdi BETWEEN (94030000) AND (94039999) OR
               cncm_pdi BETWEEN (94042000) AND (94042900) OR
               cncm_pdi BETWEEN (96060000) AND (96069999) OR
               cncm_pdi BETWEEN (96070000) AND (96079999)


    Alexandre Matayosi Conde Mauricio. Se esta sugestão for útil, por favor, classifique-a como útil. Se ela lhe ajudar a resolver o problema, por favor, marque-a como Resposta.

    • Marcado como Resposta Harley Araujo quinta-feira, 11 de outubro de 2012 13:20
    terça-feira, 9 de outubro de 2012 14:07

Todas as Respostas

  • Oi Flavia, bom dia.

    Nossa! É muito between mesmo. Particularmente eu tentaria criar uma tabela temporária com os ranges e utilizar esta tabela num Join com a tabela principal.

    Mas em relação a "travar", você já analisou o plano de execução?


    Roberson Ferreira - Database Developer
    Acesse: www.robersonferreira.com.br
    Email: contato@robersonferreira.com.br

    Se esta sugestão for útil, por favor, classifique-a como útil.
    Se ela lhe ajudar a resolver o problema, por favor, marque-a como Resposta.

    terça-feira, 9 de outubro de 2012 13:49
    Moderador
  • Bom dia Flavia, no seu campo cncm_pdi ha algum indice ? voce ja tentou dividr a query em partes ? tente fazer desta maneira :

    Rode o primeiro select, depois a criação do indice na temporaria e depois o ultimo select.

    SELECT  bethadba.efsaidas.codi_emp, 
               bethadba.efsaidas.codi_sai, 
               bethadba.efsaidas.dsai_sai,
               bethadba.efsaidas.nume_sai,
               bethadba.efsaidas.codi_cli,
               bethadba.efsaidas.I_REDUCAO, 
               bethadba.efmvspro.vpro_msp,   
               bethadba.efmvspro.vdes_msp,
               bethadba.efmvspro.vfre_msp,
               bethadba.efmvspro.vseg_msp,
               bethadba.efmvspro.vdesace_msp, 
               bethadba.efmvspro.cfop_msp, 
               bethadba.efprodutos.cncm_pdi,
               bethadba.geempre.razao_emp, 
               bethadba.geempre.cgce_emp
    into #Temp_AUX
        FROM  bethadba.efsaidas,
               bethadba.efmvspro,
               bethadba.efprodutos,
               bethadba.geempre
       WHERE 
              bethadba.efsaidas.codi_emp = 1219 AND 
              bethadba.geempre.codi_emp = 1219 AND
              bethadba.efsaidas.dsai_sai BETWEEN YMD(2012,08,01) AND YMD(2012,08,01) AND
              bethadba.efmvspro.codi_emp =bethadba.efsaidas.codi_emp AND
              bethadba.efmvspro.codi_sai = bethadba.efsaidas.codi_sai AND 
              bethadba.efprodutos.codi_pdi =bethadba.efmvspro.codi_pdi AND
              bethadba.efprodutos.codi_emp = bethadba.efsaidas.codi_emp AND   
              bethadba.efmvspro.cfop_msp IN (5101,5103,5105,5109,5111,5113,5118,5122,5124,5125,5401,5402,5501,5651,5652,5653,5922,6101,6103,6105,6107,6109,6111,6113,6118,6122,6124,6125,6401,6402,6501,6651,6652,6653,6922,7101,7105,7124,7127,7651)AND
            
    Create clustered index IX_PDI on   #Temp_AUX (cncm_pdi)
    
    select 
    	* 
    		from #Temp_AUX
    where 
              cncm_pdi NOT IN (65061000,84091000,84221110,84231000,84512100,84529020,85115090,85121000,85461000,85472010,87029010,84521000)  AND
     
             
              cncm_pdi IN (30059090,38151210,38190000,40091100,40091210,40091290,40093100,40093210,40093290,40094210,40094290,40103100,40103200,40103300,40103400,40103500,40103600,40103900,40161010,40169100,40169300,40169990,42021100,42021220,42022100,42022220,42023100,42023200,42029100,42029200,42050000,44219000,45049000,48185000,50040000,50050000,50060000,51040000,51100000,52030000,53110000,68079000,68128000,68129010,68129100,68129910,68131010,68131090,68132000,68138110,68138190,68138910,68138990,68139010,68139090,69091930,70071100,70072100,70091000,73030000,73081000,73082000,73090010,73090090,73101090,73102910,73102990,73110000,73151100,73151210,73151290,73151900,73152000,73158100,73158200,73158900,73159000,73160000,73201000,73202010,73202090,73209000,73269090,74199990,76129090,82054000,82073000,83012000,83023000,83081000,83082000,83100000,84671110,84671190,84671900,84672991,84672993,84678100,84678900,84679100,84679200,84679900,84681000,84682000,84688010,84688090,84689010,84689020,84689090,84690010,84709010,84709090,84718000,84719019,84719090,84721000,84723090,84729010,84729029,84729030,84729040,84729091,84729099,84731010,84781010,84781090,84789000,84011000,84012000,84014000,84141000,84142000,84143011,84143019,84143091,84143099,84144010,84144020,84144090,84145910,84145990,84148011,84148012,84148013,84148019,84148021,84148022,84148029,84148031,84148032,84148033,84148038,84148039,84148090,84149010,84149020,84149031,84149032,84149033,84149034,84149039,84151090,84152010,84152090,84158110,84158190,84158210,84158290,84158300,84159000,84185010,84185090,84186100,84186910,84186920,84186931,84186932,84186940,84186991,84186999,84189900,84219920,84211110,84211190,84211290,84211910,84211990,84212100,84212200,84212300,84212920,84212930,84212990,84213100,84213910,84213920,84213930,84213990,84219191,84219199,84219910,84219991,84219999,84431110,84431190,84431200,84431310,84431321,84431329,84431390,84431400,84431500,84431600,84431710,84431790,84431910,84431990,84433910,84433921,84433928,84433929,84433930,84433990,84439110,84439191,84439192,84439199,84811000,84812010,84812011,84812019,84812090,84813000,84814000,84818021,84818029,84818039,84818092,84818093,84818094,84818095,84818096,84818097,84818099,84819090,84823000,84825090,84828000,84829120,84829130,84829190,84829911,84829919,85030010,85030090,85042100,85042200,85042300,85043111,85043119,85043211,85043219,85043221,85043300,85043400,85044022,85044030,85044050,85044090,85051910,85052090,85059010,85059080,85059090,85071000,85071010,85071090,85072010,85072090,85079010,85079090,85086000,85087000,85141010,85141090,85142011,85142019,85142020,85143011,85143019,85143021,85143029,85143090,85144000,85149000,85151100,85151900,85152100,85152900,85153110,85153190,85153900,85158010,85158090,85159000,85161000,85167100,85167920,85167990,85168010,85169000,85171891,85171899,85176130,85176212,85176221,85176222,85176223,85176224,85176229,85176232,85176239,85176241,85176248,85176251,85176254,85176255,85176259,85176262,85176272,85176277,85176278,85176279,85176294,85176299,85176900,85177010,85182100,85182200,85182990,85269200,85272110,85272190,85272900,85272990,85287111,85311090,85321000,85322990,85352100,85353017,85353018,85353027,85353028,85361000,85362000,85363000,85364100,85364900,85365090,85366100,85366910,85366990,85369010,85369040,85369090,85371020,85371090,85372090,85381000,85389090,85392910,85392990,85408990,85431000,85432000,85433000,85437013,85437039,85437040,85437099,85439090,85443000,85444200,85489090,86011000,86071919,87011000,87013000,87019010,87019090,87041010,87041090,87051010,87051090,87052000,87053000,87054000,87059010,87059090,87060020,87071000,87079010,87079090,87081000,87082100,87082911,87082912,87082913,87082914,87082919,87082991,87082992,87082993,87082994,87082995,87082996,87082999,87083011,87083019,87083090,87083110,87083190,87083900,87084011,87084019,87084080,87084090,87085011,87085012,87085019,87085080,87085090,87085091,87085099,87086010,87086090,87087010,87087090,87088000,87089100,87089200,87089300,87089411,87089412,87089413,87089481,87089482,87089483,87089490,87089491,87089492,87089493,87089510,87089521,87089522,87089529,87089910,87089990,87091100,87091900,87099000,87100000,87141000,87141900,87149490,87149990,87162000,87163100,87163900,88040000,90058000,90059090,90061010,90061090,90072090,90072091,90072099,90079200,90085000,90089000,90101010,90101020,90101090,90109010,90111000,90118010,90118090,90119090,90131090,90151000,90152010,90152090,90153000,90154000,90158010,90158090,90159010,90159090,90160010,90160090,90171010,90171090,90173010,90173020,90173090,90179010,90179090,90189091,90191000,90221910,90221991,90221999,90222910,90222990,90241010,90241020,90241090,90248011,90248019,90248021,90248029,90248090,90249000,90251190,90251910,90251990,90258000,90259010,90259090,90261019,90261021,90261029,90262010,90262090,90268000,90269010,90269020,90269090,90271000,90272011,90272012,90272019,90272021,90272029,90273011,90273019,90273020,90275010,90275020,90275030,90275040,90275050,90275090,90278011,90278012,90278013,90278014,90278020,90278030,90278091,90278099,90279010,90279091,90279093,90279099,90281011,90281019,90281090,90282010,90282020,90283011,90283019,90283021,90283029,90283031,90283039,90283090,90289010,90289090,90289090,90291010,90292010,90299010,90303321,90303921,90303990,90304030,90304090,90308490,90308990,90309090,90311000,90312010,90312090,90314100,90314910,90314920,90314990,90318011,90318012,90318020,90318030,90318040,90318050,90318060,90318091,90318099,90319010,90319090,90321010,90321090,90322000,90328100,90328911,90329010,90329099,90330000,91040000,91070010,91091000,94012000,94018000,94049000,94051093,94051099,94052000,94059100,94060010,94060092,95066200,95069100,96138000) OR
              
               cncm_pdi BETWEEN (02030000) AND (02039999) OR
               cncm_pdi BETWEEN (02101000) AND (02101999) OR
               cncm_pdi BETWEEN (39150000) AND (39159999) OR
               cncm_pdi BETWEEN (39160000) AND (39169999) OR
               cncm_pdi BETWEEN (39170000) AND (39179999) OR
               cncm_pdi BETWEEN (39180000) AND (39189999) OR
               cncm_pdi BETWEEN (39190000) AND (39199999) OR
               cncm_pdi BETWEEN (39200000) AND (39209999) OR
               cncm_pdi BETWEEN (39210000) AND (39219999) OR
               cncm_pdi BETWEEN (39220000) AND (39229999) OR
               cncm_pdi BETWEEN (39230000) AND (39239999) OR
               cncm_pdi BETWEEN (39240000) AND (39249999) OR
               cncm_pdi BETWEEN (39250000) AND (39259999) OR
               cncm_pdi BETWEEN (39260000) AND (39269999) OR
               cncm_pdi BETWEEN (40150000) AND (40159999) OR
               cncm_pdi BETWEEN (41040000) AND (41049999) OR
               cncm_pdi BETWEEN (41050000) AND (41059999) OR
               cncm_pdi BETWEEN (41060000) AND (41069999) OR
               cncm_pdi BETWEEN (41070000) AND (41079999) OR
               cncm_pdi BETWEEN (41140000) AND (41149999) OR
               cncm_pdi BETWEEN (42030000) AND (42039999) OR
               cncm_pdi BETWEEN (43030000) AND (43039999) OR
               cncm_pdi BETWEEN (50070000) AND (50079999) OR
               cncm_pdi BETWEEN (51050000) AND (51059999) OR
               cncm_pdi BETWEEN (51060000) AND (51069999) OR
               cncm_pdi BETWEEN (51070000) AND (51079999) OR
               cncm_pdi BETWEEN (51080000) AND (51089999) OR
               cncm_pdi BETWEEN (51090000) AND (51099999) OR
               cncm_pdi BETWEEN (51110000) AND (51119999) OR
               cncm_pdi BETWEEN (51120000) AND (51129999) OR
               cncm_pdi BETWEEN (51130000) AND (51130099) OR
               cncm_pdi BETWEEN (52040000) AND (52049999) OR
               cncm_pdi BETWEEN (52050000) AND (52059999) OR
               cncm_pdi BETWEEN (52060000) AND (52069999) OR
               cncm_pdi BETWEEN (52070000) AND (52079999) OR
               cncm_pdi BETWEEN (52080000) AND (52089999) OR
               cncm_pdi BETWEEN (52090000) AND (52099999) OR
               cncm_pdi BETWEEN (52100000) AND (52109999) OR
               cncm_pdi BETWEEN (52110000) AND (52119999) OR
               cncm_pdi BETWEEN (52120000) AND (52129999) OR
               cncm_pdi BETWEEN (53060000) AND (53069999) OR
               cncm_pdi BETWEEN (53070000) AND (53079999) OR
               cncm_pdi BETWEEN (53080000) AND (53089999) OR
               cncm_pdi BETWEEN (53090000) AND (53099999) OR
               cncm_pdi BETWEEN (53100000) AND (53109999) OR
               cncm_pdi BETWEEN (54000000) AND (54999999) OR
               cncm_pdi BETWEEN (55000000) AND (55999999) OR
               cncm_pdi BETWEEN (56000000) AND (56999999) OR
               cncm_pdi BETWEEN (57000000) AND (57999999) OR
               cncm_pdi BETWEEN (58000000) AND (58999999) OR
               cncm_pdi BETWEEN (59000000) AND (59999999) OR
               cncm_pdi BETWEEN (60000000) AND (60999999) OR
               cncm_pdi BETWEEN (61000000) AND (61999999) OR
               cncm_pdi BETWEEN (62000000) AND (62999999) OR
               cncm_pdi BETWEEN (63000000) AND (63999999) OR
               cncm_pdi BETWEEN (64000000) AND (64999999) OR
               cncm_pdi BETWEEN (65000000) AND (65999999) OR
               cncm_pdi BETWEEN (84020000) AND (84029999) OR
               cncm_pdi BETWEEN (84030000) AND (84039999) OR
               cncm_pdi BETWEEN (84040000) AND (84049999) OR
               cncm_pdi BETWEEN (84050000) AND (84059999) OR
               cncm_pdi BETWEEN (84060000) AND (84069999) OR
               cncm_pdi BETWEEN (84070000) AND (84079999) OR
               cncm_pdi BETWEEN (84080000) AND (84089999) OR
               cncm_pdi BETWEEN (84090000) AND (84999999) OR
               cncm_pdi BETWEEN (84100000) AND (84109999) OR
               cncm_pdi BETWEEN (84110000) AND (84119999) OR
               cncm_pdi BETWEEN (84120000) AND (84129999) OR
               cncm_pdi BETWEEN (84130000) AND (84139999) OR
               cncm_pdi BETWEEN (84160000) AND (84169999) OR
               cncm_pdi BETWEEN (84170000) AND (84179999) OR
               cncm_pdi BETWEEN (84190000) AND (84199999) OR
               cncm_pdi BETWEEN (84200000) AND (84209999) OR
               cncm_pdi BETWEEN (84220000) AND (84229999) OR
               cncm_pdi BETWEEN (84230000) AND (84239999) OR
               cncm_pdi BETWEEN (84240000) AND (84249999) OR
               cncm_pdi BETWEEN (84250000) AND (84259999) OR
               cncm_pdi BETWEEN (84260000) AND (84269999) OR
               cncm_pdi BETWEEN (84270000) AND (84279999) OR
               cncm_pdi BETWEEN (84280000) AND (84289999) OR
               cncm_pdi BETWEEN (84290000) AND (84299999) OR
               cncm_pdi BETWEEN (84300000) AND (84309999) OR
               cncm_pdi BETWEEN (84310000) AND (84319999) OR
               cncm_pdi BETWEEN (84320000) AND (84329999) OR
               cncm_pdi BETWEEN (84330000) AND (84339999) OR
               cncm_pdi BETWEEN (84340000) AND (84349999) OR
               cncm_pdi BETWEEN (84350000) AND (84359999) OR
               cncm_pdi BETWEEN (84360000) AND (84369999) OR
               cncm_pdi BETWEEN (84370000) AND (84379999) OR
               cncm_pdi BETWEEN (84380000) AND (84389999) OR
               cncm_pdi BETWEEN (84390000) AND (84399999) OR
               cncm_pdi BETWEEN (84400000) AND (84409999) OR
               cncm_pdi BETWEEN (84410000) AND (84419999) OR
               cncm_pdi BETWEEN (84420000) AND (84429999) OR
               cncm_pdi BETWEEN (84440000) AND (84449999) OR
               cncm_pdi BETWEEN (84450000) AND (84459999) OR
               cncm_pdi BETWEEN (84460000) AND (84469999) OR
               cncm_pdi BETWEEN (84470000) AND (84479999) OR
               cncm_pdi BETWEEN (84480000) AND (84489999) OR
               cncm_pdi BETWEEN (84490000) AND (84499999) OR
               cncm_pdi BETWEEN (84502000) AND (84502099) OR
               cncm_pdi BETWEEN (84510000) AND (84519999) OR
               cncm_pdi BETWEEN (84510000) AND (84519999) OR
               cncm_pdi BETWEEN (84530000) AND (84539999) OR
               cncm_pdi BETWEEN (84540000) AND (84549999) OR
               cncm_pdi BETWEEN (84550000) AND (84559999) OR
               cncm_pdi BETWEEN (84560000) AND (84569999) OR
               cncm_pdi BETWEEN (84570000) AND (84579999) OR
               cncm_pdi BETWEEN (84580000) AND (84589999) OR
               cncm_pdi BETWEEN (84590000) AND (84599999) OR
               cncm_pdi BETWEEN (84600000) AND (84609999) OR
               cncm_pdi BETWEEN (84610000) AND (84619999) OR
               cncm_pdi BETWEEN (84620000) AND (84629999) OR
               cncm_pdi BETWEEN (84630000) AND (84639999) OR
               cncm_pdi BETWEEN (84640000) AND (84649999) OR
               cncm_pdi BETWEEN (84650000) AND (84659999) OR
               cncm_pdi BETWEEN (84660000) AND (84669999) OR
               cncm_pdi BETWEEN (84740000) AND (84749999) OR
               cncm_pdi BETWEEN (84750000) AND (84759999) OR
               cncm_pdi BETWEEN (84760000) AND (84769999) OR
               cncm_pdi BETWEEN (84770000) AND (84779999) OR
               cncm_pdi BETWEEN (84790000) AND (84799999) OR
               cncm_pdi BETWEEN (84800000) AND (84809999) OR
               cncm_pdi BETWEEN (84830000) AND (84839999) OR
               cncm_pdi BETWEEN (84831010) AND (84831019) OR
               cncm_pdi BETWEEN (84840000) AND (84849999) OR
               cncm_pdi BETWEEN (84860000) AND (84869999) OR
               cncm_pdi BETWEEN (84870000) AND (84879999) OR
               cncm_pdi BETWEEN (85010000) AND (85019999) OR
               cncm_pdi BETWEEN (85020000) AND (85029999) OR
               cncm_pdi BETWEEN (85110000) AND (85119999) OR
               cncm_pdi BETWEEN (85120000) AND (85129999) OR
               cncm_pdi BETWEEN (85130000) AND (85139999) OR
               cncm_pdi BETWEEN (85410000) AND (85419999) OR
               cncm_pdi BETWEEN (85460000) AND (85469999) OR
               cncm_pdi BETWEEN (85470000) AND (85479999) OR
               cncm_pdi BETWEEN (87020000) AND (87029999) OR
               cncm_pdi BETWEEN (87070000) AND (87079999) OR
               cncm_pdi BETWEEN (88020000) AND (88029999) OR
               cncm_pdi BETWEEN (88030000) AND (88039999) OR
               cncm_pdi BETWEEN (89000000) AND (89999999) OR
               cncm_pdi BETWEEN (90328920) AND (90328929) OR
               cncm_pdi BETWEEN (90328980) AND (90328989) OR
               cncm_pdi BETWEEN (94013000) AND (94013099) OR
               cncm_pdi BETWEEN (94014000) AND (94014099) OR
               cncm_pdi BETWEEN (94015000) AND (94015999) OR
               cncm_pdi BETWEEN (94016000) AND (94016999) OR
               cncm_pdi BETWEEN (94017000) AND (94017999) OR
               cncm_pdi BETWEEN (94019000) AND (94019999) OR
               cncm_pdi BETWEEN (94020000) AND (94029999) OR
               cncm_pdi BETWEEN (94030000) AND (94039999) OR
               cncm_pdi BETWEEN (94042000) AND (94042900) OR
               cncm_pdi BETWEEN (96060000) AND (96069999) OR
               cncm_pdi BETWEEN (96070000) AND (96079999)


    Alexandre Matayosi Conde Mauricio. Se esta sugestão for útil, por favor, classifique-a como útil. Se ela lhe ajudar a resolver o problema, por favor, marque-a como Resposta.

    • Marcado como Resposta Harley Araujo quinta-feira, 11 de outubro de 2012 13:20
    terça-feira, 9 de outubro de 2012 14:07