You are on page 1of 16

--Declaration

declare
@iDay int,
@iMaxDay int,
@iMinDay int,
@iActiveLocs int,
@iPostedLocs int,
@iMissingLocCount int
select @iMinDay = 2
select @iMaxDay = 10
set @iDay = @iMaxDay
--set @iDay = 1
--Creating table
create table #MissingCPSTCount (BusinessDate datetime, icount int)
create table #MissingCPSTStore (BusinessDate datetime, iStore varchar(20))
--Active locations count
select @iActiveLocs = count(*) from compass_01_wh..loc_bu as b (nolock)
where active='y' and name in ('04008','04015','04016','04017','04018','04021','0
4022','04023','01018','01019','01021','04003','01002','01003','01006','01010','0
1011','01012','01013','04028','04030','04031','04032','04033','04036','04038','0
4040','04042','04049','04050','04051','04052','04053','04054','04055','04057','0
4058','04059','04061','04062','04064','04067','04069','06001','06032','06036','0
6038','06053','06058','06059','06060','06066','06067','06068','06073','06075','0
6083','06087','06094','06095','06098','06099','06100','06113','06117','06118','0
6120','06122','06129','06145','06149','06151','06160','06163','06175','06176','0
6178','06179','06182','06189','06191','06192','06200','06202','06205','06207','0
6209','06219','06220','06222','06224','06236','06238','06239','06245','06248','0
6250','06253','06255','06262','06265','06266','06268','06270','06272','06276','0
6282','06288','06293','06294','06295','06298','06300','06301','06303','06313','0
6315','06316','06317','06319','06320','06321','06322','06323','06324','06325','0
6326','06328','06329','06333','06334','06336','06338','06343','06344','06346','0
6347','06349','06351','06354','06357','06358','06359','06362','06363','06381','0
6383','06385','06387','06389','06390','06391','06392','06394','06395','06396','0
6398','06405','06410','06411','06416','06425','06426','06428','06430','06431','0
6433','06438','06440','06441','06442','06449','06451','06454','06455','06461','0
6463','06466','06467','06470','06472','06473','06477','06479','06480','06485','0
6486','06489','06490','06492','06502','06503','06505','06506','06508','06511','0
6513','06517','06522','06525','06530','06534','06542','06549','06555','06556','0
6560','06562','06568','06569','06571','06572','06574','06580','06581','06582','0
6584','06588','06592','06593','06595','06704','06707','06717','06721','06722','0
6725','06727','06729','06731','06734','06735','06742','06755','06764','06768','0
6772','06785','06790','06791','06792','06794','06804','06808','06811','06814','0
6828','06835','06841','06845','06846','06848','06850','08001','08002','08004','0
8005','08006','08009','08025','08028','08030','08031','08033','08034','08039','0
8042','08043','08046','08052','08054','08064','08067','08068','08071','08076','0
8080','08081','08082','08083','08085','08090','08099','08101','08103','09003','0
9013','09014','09015','09019','09022','09025','09026','09027','09031','09036','1
2002','12005','12008','12009','12013','12014','12016','12017','12019','12022','1
2025','12027','12029','12030','12033','12034','12036','12040','12042','12046','1
2049','12054','12055','12057','12061','12062','12066','12071','12074','12078','1
2081','12085','12089','12091','12095','12103','12111','12113','12114','12115','1
2121','12127','12132','12135','12138','12148','12149','12152','12153','12164','1
2165','12166','12167','12168','12172','12173','12176','12177','12182','12184','1
2185','12186','12187','12190','12195','12196','12198','12199','12201','12203','1
2207','12208','12209','12212','12213','12215','12216','12219','12221','12223','1
2224','12225','12227','12229','12230','12231','12232','12235','12237','12238','1
2240','12241','12242','12244','12247','12257','12261','12266','12268','12269','1
2270','12271','12272','12274','12275','12280','12281','12282','12283','12284','1
2289','12290','12294','12295','12296','12300','12301','12305','12306','12312','1
2318','12320','12323','12325','12329','12333','12334','12336','12337','12338','1
2342','12345','12358','12369','12372','12377','12391','12393','13002','13012','1
3015','13029','13044','13045','13047','13049','13051','13052','13055','13056','1
3059','13067','13068','13070','13071','13077','13079','13082','13084','13085','1
3086','13087','13089','13090','13091','13092','13093','13094','13100','13101','1
3105','13106','13107','13109','13111','13116','13117','13118','13119','13123','1
3125','13128','13129','13146','13150','13154','13165','13170','13172','13173','1
3175','13177','13178','13184','15001','15003','15006','17001','17009','17011','1
7016','17017','17019','17025','17026','17027','17030','17033','17034','17039','1
7046','17048','17053','17054','17063','17071','17205','17206','17211','17212','1
7213','17216','17218','17223','17229','17230','17232','17236','17238','17239','1
7240','17244','17246','17250','17253','17257','17259','17261','17263','17268','1
7275','17278','17281','17282','17291','17293','17294','17296','17298','17307','1
7311','17318','17325','17327','17328','17329','17330','17334','17335','17336','1
7340','17341','17343','17346','17350','17353','17354','17356','17359','17362','1
7364','17365','17366','17368','17370','17388','18511','18519','18527','18528','1
8540','18541','18545','18549','18550','18551','18552','18553','18559','18560','1
8562','18567','18568','18569','18572','18574','18577','18578','18579','18584','1
8585','19003','19004','19008','19010','19011','19016','19022','19023','19024','1
9025','19026','19028','19029','19030','19031','19032','19033','20003','20014','2
0016','20023','20027','20029','20031','20033','21002','21003','21005','21006','2
1007','21013','21401','21402','21404','21408','21410','22009','22010','22011','2
2012','22013','22020','22027','22029','22030','22032','22033','22034','22035','2
2037','22039','22040','22043','22046','22048','22049','22052','22056','22057','2
2065','22066','22068','23010','23013','24009','24021','24073','24076','24082','2
4083','24084','24092','24100','24101','24110','24111','24124','24127','25001','2
5009','25011','25020','25026','25028','25029','25033','25038','25053','25058','2
5069','25070','25071','25072','25078','26002','26007','26008','26009','26012','2
6013','26014','26019','26025','26028','26029','26031','26032','26033','26039','2
6043','26046','26047','26052','26053','26055','26056','26062','26063','26066','2
6073','26074','26075','26079','26084','26085','26086','26088','26089','26092','2
6094','26100','26101','26102','26105','26106','26109','26110','26111','26112','2
6113','26122','26123','26124','26127','26128','26130','26142','26143','26144','2
6148','26149','26152','26154','26156','26158','26159','26176','26178','26181','2
7004','27008','27012','27014','27016','27023','27024','27025','27037','28002','2
8003','28008','28018','28020','28025','28026','29003','29014','29015','29026','2
9028','29029','29031','29037','29040','29041','29042','29043','29048','29055','2
9063','29071','29072','29075','29076','29081','29083','29086','29088','29091','2
9092','29094','29096','29098','29104','29118','29120','29121','29123','29127','2
9129','29138','29140','29141','29142','29143','29147','29156','29158','29159','2
9161','29162','31007','31014','31029','31035','31041','31043','31045','31046','3
1051','31053','31055','32017','32020','32022','32023','32025','32026','32028','3
2030','32034','32035','32038','33004','33006','33008','33009','33010','33011','3
3017','34002','34008','34015','34024','34030','34035','34037','34043','34048','3
4050','34051','34053','34055','34067','34068','34076','34078','34082','34090','3
4092','34093','34099','34100','34102','34103','34105','34108','34110','34111','3
4112','34113','34120','34132','36002','36003','36014','36016','36030','36035','3
6041','36046','36048','36050','36053','36058','36067','36072','36075','36080','3
6081','36086','36092','36112','36123','36131','36132','36140','36146','36147','3
6149','36157','36159','36162','36163','36164','36165','36168','36169','36170','3
6180','36182','36190','36191','36194','36202','36204','36207','36214','36216','3
6220','36231','36233','36246','36256','36258','36259','36262','36264','36267','3
6268','36273','36275','36277','36299','36300','36302','36306','36310','36321','3
6322','36334','36338','36507','36508','36512','36514','36515','36516','36805','3
6806','36814','36815','36826','36828','36832','36833','36837','36839','36840','3
6841','37000','37002','37008','37009','37010','37011','37012','37013','37014','3
7017','37018','37020','37024','37025','37028','37034','37035','37044','37047','3
7051','37052','37058','37059','37065','37069','37070','39302','39303','39309','3
9312','39324','39326','39327','39329','39338','39339','39340','39342','39344','3
9345','39346','39347','39354','39360','39363','39364','39365','39369','39371','3
9382','39386','39393','39401','39408','39409','39419','39420','39427','39430','3
9433','39445','39446','39450','39455','39456','39462','39477','39478','39480','3
9491','39496','39499','40007','40011','40013','40019','40020','40021','40030','4
0036','40037','40038','40040','40041','40042','40043','40044','40045','40046','4
0047','40048','40049','40050','40054','40063','40064','40068','40073','41001','4
1003','41004','42006','42017','42022','42024','42029','42030','42033','42043','4
2046','42054','42057','42059','42060','42064','42065','42069','42073','42076','4
2077','42085','42089','42092','42095','42098','42104','42113','42117','42119','4
2127','42141','42153','42158','42160','45002','45005','45006','45007','45009','4
5010','45012','45015','45019','45025','45026','45027','45028','45033','45034','4
5036','47004','47005','47007','47011','47012','47017','47018','47021','48002','4
8018','48019','48021','48027','48028','48034','48041','48042','48045','48051','4
8052','48061','48069','48071','48072','48075','48079','48080','48081','48082','4
8101','48104','48117','48118','48126','48129','48131','48138','48139','48140','4
8141','48146','48147','48149','48152','48156','48157','48160','48164','48166','4
8169','48170','48176','48178','48181','48182','48184','48185','48188','48197','4
8205','48206','48208','48220','48225','48232','48236','48237','48244','48248','4
8249','48250','48255','48258','48262','48263','48265','48268','48270','48279','4
8282','48283','48290','48294','48295','48307','48308','48311','48312','48314','4
8319','48322','48325','48329','48336','48339','48342','48343','48344','48346','4
8347','48349','48352','48358','48359','48360','48361','48362','48372','48373','4
8381','48386','48400','48401','48412','48413','48417','48419','48422','48423','4
8437','48438','48440','48441','48451','48452','48454','48458','48459','48462','4
8464','48469','48480','48482','48484','48493','48498','48500','48902','48909','4
8914','48926','48928','48930','48931','49008','49011','49012','49013','49014','4
9018','49020','49023','49035','49041','49042','49043','49051','49053','49054','4
9057','50001','50002','50003','50006','51007','51008','51009','51012','51013','5
1017','51019','51022','51023','51024','51031','51032','51036','51037','51040','5
1042','51043','51044','51046','51047','51048','51057','51059','51061','52003','5
2004','52006','52008','52010','52012','54003','54005','54006','54008','54011','5
5002','55008','55012','55015','55017','55018','55020','55021','55022','55025','5
5033','55704','55709','55710','55721','55722','55723','55724','90006','90007','9
0026','90027','90030','90031','90034','90035','90038','90043','90078','90081','9
0082','90093','90094','90101','90105','90151','90153','90154','90157','90159','9
0166','90167','90186','90188','90192','90193','90232','90233','90264','90301','9
0305','90307','90309','90313','90315','90317','90318','90319','90323','90327','9
0329','90330','90331','90332','90336','90337','90338','90340','90343','90348','9
0350','90351','90354','90355','90358','90359','90360','90361','90366','90369','9
0371','90373','90376','90378','90379','90380','90385','90386','90388','90389','9
0394','90395','90396','90428','90430','90432','90433','90435','90437','90438','9
0439','90440','90441','90442','90478','90502','90504','90514','90521','90522','9
0523','90529','90531','90533','90535','90536','90538','90539','90541','90544','9
0549','90561','90576','90577','90580','90583','90590','90591','90593','90602','9
0604','90605','90612','90653','90686','90702','90704','90726','90803','90806','9
0808','91001','91006','91008','91009','91190','91222','91223','91224','91236','9
1255','91262','91269','91270','91271','91274','91281','91282','91303','91304','9
1322','91324','91325','91326','91352','91353','91354','91355','91426','91428','9
1429','91437','91442','91444','91449','91451','91458','91477','91478','91576','9
1577','91578','91603','91604','91605','91608','91611','91612','91614','91616','9
1617','91620','91652','91653','91654','91676','91701','91705','91707','91708','9
1726','91826','91833','91901','91907','91929','91931','91932','91933','91936','9
1951','91952','91954','91955','91957','91958','91961','91962','91964','91965','9
1966','91967','91969','91971','92027','92028','92102','92103','92113','92115','9
2117','92120','92121','92122','92124','92209','92215','92226','92252','92274','9
2275','92280','92281','92294','92295','92299','92305','92306','92307','92427','9
2428','92452','92453','92457','92459','92461','92462','92470','92475','92489','9
2491','92493','92494','92495','92496','92506','92508','92509','92510','92511','9
2512','92513','92514','92515','92517','92518','92520','92523','92524','92531','9
2532','92554','92555','92556','92559','92562','92563','92564','92565','92566','9
2568','92569','92572','92576','92577','92579','92581','92582','92583','92584','9
2588','92590','92591','92593','92594','92597','92598','92600','92601','92604','9
2605','92606','92609','92611','92613','92617','92618','92623','92624','92626','9
2628','92629','92632','92634','92637','92638','92640','92641','92642','92643','9
2647','92649','92656','92684','92750','92751','92754','92755','92756','92757','9
2758','92760','92762','92763','92764','92767','92769','92772','92776','92778','9
2779','92782','92783','92785','92801','92803','92804','92807','92813','92814','9
2816','92817','92818','92819','92823','92825','92827','92829','92830','92831','9
2835','92836','94000','94026','94027','94028','94029','94031','94032','94035','9
4036','94041','94042','94043','94044','94045','94046','94047','94048','94061','9
4063','94099','94100','94102','94104','94109','94126','94130','94240','94241','9
5056','95058','95061','95062','95063','95078','95083','95084','95087','95104','9
5150','95156','95157','95158','95160','95163','95164','95208','95209','95229','9
5325','95326','95329','95330','95331','95332','95334','95335','95336','95337','9
5340','95341','95344','95345','95346','95347','95348','95349','95390','95391','9
5392','95393','95394','95395','95396','95397','95398','95401','95428','95429','9
5576','95612','95651','95652','95681','95727','95728','95801','95826','95827','9
5828','95852','96076','96078','96079','96115','97038','97039','97076','97176','9
7178','97179','97180','97201','97276','97279','97280','37072','39500','90957','2
2073','94245','95653','51064','51065','92463','12396','48933','48934','36854','2
6182','48936','55726','17393','40075','09050','37074','18589','48937','48938','0
8108','04070','32041','06854','06855','48941','17395','26183','06856','28027','0
1029','22074','39504','48942','48945','48946','34133','42205','12397','01030','2
1414','06859','26185','06860','06861','26186','17102','17101','49062','95926','1
3199','04071','04072','04073','95389','95388','26188','48950','22079','29174','4
8954','97204','12398','06866','06865','06864','06870','48958','48959','12401','1
2402','36856','08114','48963','48961','48960','55046','55048','55051','55052','5
5053','55059','17404','42208','42209','51071','51073','24132','95387','49063','0
6873','08115','34136','06874','21415','27041','39505','13202','52015','06877','1
3205','13204','08117','48507','39506','36523','36522','12405','12404','06878','0
6879','06881','95385','92665','29175','17412','39508','48970','39512','04074','2
6189','13217','13215','94247','06885','41009','41008','49066','29176','42212','2
5083','49067','48509','48512','08120','95374','04075','12406','32048','32046','3
2045','04076','04077','09052','36858','08121','06896','06898','48972','26190','5
5730','39514','08126','40079','17430','26192','39516','17426','17433','04080','4
9069','48523','15009','15010','06748','29177','20039','20040','37079','37080','0
1033','08134','48528','48530','06217','39517','09054','09055','34142','37081','3
4147','34143','47028','49071','49072','52018','52019','52024','52027','41015','4
1017','48984','32052','04082','04083','04084','06612','06616','06620','06623','0
6630','10003','12415','12411','37082','04091','04092','18592','17442','06637','0
6645','52828','52835','52838','47029','40083','48987','48990','26193','36863','3
4151','34150','34149','52028','41025','41027','41028','41029','52030','52031','5
2050','52051','52055','06650','06654','36350','36351','36866','26195','48995','4
2162','42165','42166','13223','12424','48536','29193','40084','31061','06661','5
2066','06667','06668','06670','06676','06677','06679','06680','06682','06686','0
6687','06688','39519','37089','24148','29197','26196','06691','06694','34153','1
3224','02513','55735','34154','52074','52076','41045','52079','52083','41050','4
1051','52084','41054','52088','52090','52091','41055','41057','41060','41064','4
1065','41071','41072','42224','42225','48565','12427','52839','02518','26199','2
6200','12430','12431','42227','48567','17461','02521','02524','02527','02530','0
2533','52843','52842','45061','24149','52093','39524','08144','12441','36354','1
2442','12443','42232','26202','02539','04100','04102','18598','02544','18600','1
3232','13234','09060','25096','29199','37093','39527','34158','39528','04103','0
2549','02553','02555','02559','49076','49077','52096','52104','40087','40090','3
4159','34161','36540','02563','42233','02564','12450','01036','42236','37096','4
2169','02566','02568','52116','39533','02575','04106','39535','51082','37098','4
5068','02583','45070','45071','12452','02588','02589','48579','34164','42239','9
0978','52118','41085','41086','12462','12464','02591','02595','41087','41088','4
1089','02599','02600','12468','02606','02609','41092','40093','48581','48582','9
2437','52121','52122','42246','21433','27045','55739','17483','39537','34170','1
2473','04109','12474','02614','25101','09064','22088','02617','42248','36546','2
1435','41096','52124','52125','49082','54017','42249','41097','04115','26215','4
8589','26216','12476','26218','26217','39539','41099','42254','34175','37102','1
7488','41052','41062','26220','26221','04065','06475','08045','17029','21008','2
6072','29125','36178','48203','48217','95386','97281','49083','49084','48591','4
8592','20044','04116','31066','47034','26223','25106','22090','42172','48595','3
1067','17103','49085','12479','41100','48596','04117','12480','12481','34178','5
2129','37105','51088','01025','04041','06309','06434','06499','06515','06540','0
6552','06566','06709','06843','08008','12043','12092','12116','12142','12202','1
2234','12278','12314','12351','13130','13152','13194','17036','17077','17226','1
7260','18575','21015','22041','23012','25010','25068','26030','26157','26173','2
7017','29134','31042','34096','34107','36064','36181','36199','36218','36232','3
7042','39310','39335','39392','39406','39415','40022','42081','48151','48172','4
8253','48301','48315','48340','48429','48448','48485','51016','51038','55715','9
0162','90349','90362','90431','91956','92109','92289','92472','92497','92560','9
2578','92599','92620','92636','92781','94033','94108','95333','95611','26184','1
2403','49064','17415','32047','36860','06621','39518','12420','25088','12423','1
3222','18594','51075','06692','52082','39522','17466','37101','12458','04113','1
2486','12484','51090','51091','04119','12487','42177','37107','39540','39541','4
8600','52845','12488','26226','10005','12489','02646','92943','28030','02649','0
2650','31068','29214','29211','26227','34185','39545','39546','39547','12490','1
2491','26229','34186','51092','48603','42180','41104','02654','12493','15013','3
2062','32064','32065','02658','91648','18612','18613','55062','42181','40098','0
2659','91647','34190','12495','12496','48606','02662','92889','41105','18615','3
4192','52134','52135','48608','12497','12498','42183','40101','40100','22093','0
4122','04123','04124','02672','48613','12500','04126','48615','17109','02675','3
4194','02678','13242','95097','15014','26230','54023','32066','12502','02682','0
2681','02680','48617','08152','40102','27046','26232','02684','91665','40103','9
2948','37109','02687','04127','48619','02688','48620','22095','08153','12504','3
7111','34195','95456','12506','02691','15015','04128','12509','12510','26233','3
9550','91646','04130','04132','49091','55064','08154','31070','26236','26235','3
9551','55065','02695','34198','34199','48626','01045','02697','12514','47035','4
8628','48629','22096','39554','39552','34200','34203','47036','40104','12517','3
2067','27048','01050','39556','39557','39559','06904','55067','13245','39561','4
8631','50007','36377','45076','90209','48632','48633','13247','48634','29218','4
9093','27049','27053','27054','34205','51098','12520','02704','37114','36384','1
2521','17116','21019','19059','29222','42266','36389','12522','12524','54025','2
6238','92892','48637','48638','22097','22098','08156','08158','02713','13249','4
5078','40105','23026','17117','18623','18624','37117','02715','02716','52144','3
7118','13250','04136','52847','02721','37221','24171','40106','48701','39570','2
6240','25116','13253','13252','37234','37233','17371','45083','13256','42275','3
9576','12530','18629','36550','47042','12531','51100','51102','51103','13259','5
2145','40107','40108','40109','02728','02731','02732','12532','12533','39577','3
7235','32068','52848','48656','04139','48660','36561','48670','13263','15016','1
3264','26250','45090','06908','39574','13265','08160','45091','48668','26247','0
6910','42291','37225','06909','51104','08161','13266','12537','51105','29225','2
9226','12528','48675','49096','22102','22103','04140','04141','27081','55074','3
6576','37236','47046','29227','36936','18636','18637','36393','36394','26255','2
4180','51107','39586','12539','12540','12541','13267','42296','34224','18638','0
6915','02737','02738','47049','37245','91645','15017','04142','13268','41116','1
3269','51108','25121','12542','25123','17496','47050','32069','47051','40111','0
4143','22106','23027','92992','42300','41118','52152','37246','12543','12544','1
3272','23028','48707','48710','51109','08163','06918','55076','12546','50009','5
2849','52850','45099','32070','48672','36938','36939','37247','21441','48669','0
8164','45085','36940','39588','55740','52851','08165','36941','13273','12557','4
2302','12559','06927','39590','36942','36943','04144','04145','26258','29228','4
7053','12561','37250','55741','92993','29229','02739','90982','48715','02743','1
2562','37251','52852','37252','01064','02745','02746','08166','48690','42310','4
5103','28031','49100','08168','12564','08167','49101','49103','36946','12565','3
7253','37254','52854','04149','92996','01065','08174','02751','17501','28032','2
8033','36947','06971','33028','12567','37272','55742','48693','36949','22110','4
0116','52858','08175','06931','32071','09071','48718','29231','13275','04150','3
6959','50010','12571','04151','04152','04153','02756','48899','32075','48736','0
2776','55745','52147','02777','25129','54030','04156','42314','51123','41120','3
2076','25132','08181','08182','48697','92899','32077','32078','02781','48698','3
4231','25133','25134','48737','06981','41121')
print 'Active locations count ' + convert(varchar,@iActiveLocs)

While @iDay > = @iMinDay


begin
set @iPostedLocs = 0
select @iPostedLocs = count(distinct cpst_bu_id)
from
( select a.business_date business_date, a.bu_id cpst_bu_id, b.b
u_id open_bu_id
from
compass_01_wh..f_gen_sales_dest_bu_day as a (nolock)
right outer join
compass_01_wh..loc_bu as b (nolock)
on
a.bu_id=b.bu_id and
b.active ='y'-- and b.name='08164'
where a.business_date = convert(varchar(10), getdate()-@iDay,
112)
and a.bu_id is not null
) labor
group by labor.business_date
print 'Posted locations count: ' + convert(varchar,isnull(@iPostedLocs,0))
select @iMissingLocCount = @iActiveLocs - isnull(@iPostedLocs,0)
if @iMissingLocCount <0
set @iMissingLocCount=abs(@iMissingLocCount)
print 'Missing locations count: ' + convert(varchar,@iMissingLocCount)
insert into #MissingCPSTCount values (convert(varchar(10), getdate()-@iDay, 120
), @iMissingLocCount)
insert into #MissingCPSTStore
select convert(varchar(10), getdate()-@iDay, 120),name from compass_01_wh..loc_b
u
where bu_id in
(select distinct bu_id from compass_01_wh..loc_bu
where active='y' and name in ('04008','04015','04016','04017','04018','04021','0
4022','04023','01018','01019','01021','04003','01002','01003','01006','01010','0
1011','01012','01013','04028','04030','04031','04032','04033','04036','04038','0
4040','04042','04049','04050','04051','04052','04053','04054','04055','04057','0
4058','04059','04061','04062','04064','04067','04069','06001','06032','06036','0
6038','06053','06058','06059','06060','06066','06067','06068','06073','06075','0
6083','06087','06094','06095','06098','06099','06100','06113','06117','06118','0
6120','06122','06129','06145','06149','06151','06160','06163','06175','06176','0
6178','06179','06182','06189','06191','06192','06200','06202','06205','06207','0
6209','06219','06220','06222','06224','06236','06238','06239','06245','06248','0
6250','06253','06255','06262','06265','06266','06268','06270','06272','06276','0
6282','06288','06293','06294','06295','06298','06300','06301','06303','06313','0
6315','06316','06317','06319','06320','06321','06322','06323','06324','06325','0
6326','06328','06329','06333','06334','06336','06338','06343','06344','06346','0
6347','06349','06351','06354','06357','06358','06359','06362','06363','06381','0
6383','06385','06387','06389','06390','06391','06392','06394','06395','06396','0
6398','06405','06410','06411','06416','06425','06426','06428','06430','06431','0
6433','06438','06440','06441','06442','06449','06451','06454','06455','06461','0
6463','06466','06467','06470','06472','06473','06477','06479','06480','06485','0
6486','06489','06490','06492','06502','06503','06505','06506','06508','06511','0
6513','06517','06522','06525','06530','06534','06542','06549','06555','06556','0
6560','06562','06568','06569','06571','06572','06574','06580','06581','06582','0
6584','06588','06592','06593','06595','06704','06707','06717','06721','06722','0
6725','06727','06729','06731','06734','06735','06742','06755','06764','06768','0
6772','06785','06790','06791','06792','06794','06804','06808','06811','06814','0
6828','06835','06841','06845','06846','06848','06850','08001','08002','08004','0
8005','08006','08009','08025','08028','08030','08031','08033','08034','08039','0
8042','08043','08046','08052','08054','08064','08067','08068','08071','08076','0
8080','08081','08082','08083','08085','08090','08099','08101','08103','09003','0
9013','09014','09015','09019','09022','09025','09026','09027','09031','09036','1
2002','12005','12008','12009','12013','12014','12016','12017','12019','12022','1
2025','12027','12029','12030','12033','12034','12036','12040','12042','12046','1
2049','12054','12055','12057','12061','12062','12066','12071','12074','12078','1
2081','12085','12089','12091','12095','12103','12111','12113','12114','12115','1
2121','12127','12132','12135','12138','12148','12149','12152','12153','12164','1
2165','12166','12167','12168','12172','12173','12176','12177','12182','12184','1
2185','12186','12187','12190','12195','12196','12198','12199','12201','12203','1
2207','12208','12209','12212','12213','12215','12216','12219','12221','12223','1
2224','12225','12227','12229','12230','12231','12232','12235','12237','12238','1
2240','12241','12242','12244','12247','12257','12261','12266','12268','12269','1
2270','12271','12272','12274','12275','12280','12281','12282','12283','12284','1
2289','12290','12294','12295','12296','12300','12301','12305','12306','12312','1
2318','12320','12323','12325','12329','12333','12334','12336','12337','12338','1
2342','12345','12358','12369','12372','12377','12391','12393','13002','13012','1
3015','13029','13044','13045','13047','13049','13051','13052','13055','13056','1
3059','13067','13068','13070','13071','13077','13079','13082','13084','13085','1
3086','13087','13089','13090','13091','13092','13093','13094','13100','13101','1
3105','13106','13107','13109','13111','13116','13117','13118','13119','13123','1
3125','13128','13129','13146','13150','13154','13165','13170','13172','13173','1
3175','13177','13178','13184','15001','15003','15006','17001','17009','17011','1
7016','17017','17019','17025','17026','17027','17030','17033','17034','17039','1
7046','17048','17053','17054','17063','17071','17205','17206','17211','17212','1
7213','17216','17218','17223','17229','17230','17232','17236','17238','17239','1
7240','17244','17246','17250','17253','17257','17259','17261','17263','17268','1
7275','17278','17281','17282','17291','17293','17294','17296','17298','17307','1
7311','17318','17325','17327','17328','17329','17330','17334','17335','17336','1
7340','17341','17343','17346','17350','17353','17354','17356','17359','17362','1
7364','17365','17366','17368','17370','17388','18511','18519','18527','18528','1
8540','18541','18545','18549','18550','18551','18552','18553','18559','18560','1
8562','18567','18568','18569','18572','18574','18577','18578','18579','18584','1
8585','19003','19004','19008','19010','19011','19016','19022','19023','19024','1
9025','19026','19028','19029','19030','19031','19032','19033','20003','20014','2
0016','20023','20027','20029','20031','20033','21002','21003','21005','21006','2
1007','21013','21401','21402','21404','21408','21410','22009','22010','22011','2
2012','22013','22020','22027','22029','22030','22032','22033','22034','22035','2
2037','22039','22040','22043','22046','22048','22049','22052','22056','22057','2
2065','22066','22068','23010','23013','24009','24021','24073','24076','24082','2
4083','24084','24092','24100','24101','24110','24111','24124','24127','25001','2
5009','25011','25020','25026','25028','25029','25033','25038','25053','25058','2
5069','25070','25071','25072','25078','26002','26007','26008','26009','26012','2
6013','26014','26019','26025','26028','26029','26031','26032','26033','26039','2
6043','26046','26047','26052','26053','26055','26056','26062','26063','26066','2
6073','26074','26075','26079','26084','26085','26086','26088','26089','26092','2
6094','26100','26101','26102','26105','26106','26109','26110','26111','26112','2
6113','26122','26123','26124','26127','26128','26130','26142','26143','26144','2
6148','26149','26152','26154','26156','26158','26159','26176','26178','26181','2
7004','27008','27012','27014','27016','27023','27024','27025','27037','28002','2
8003','28008','28018','28020','28025','28026','29003','29014','29015','29026','2
9028','29029','29031','29037','29040','29041','29042','29043','29048','29055','2
9063','29071','29072','29075','29076','29081','29083','29086','29088','29091','2
9092','29094','29096','29098','29104','29118','29120','29121','29123','29127','2
9129','29138','29140','29141','29142','29143','29147','29156','29158','29159','2
9161','29162','31007','31014','31029','31035','31041','31043','31045','31046','3
1051','31053','31055','32017','32020','32022','32023','32025','32026','32028','3
2030','32034','32035','32038','33004','33006','33008','33009','33010','33011','3
3017','34002','34008','34015','34024','34030','34035','34037','34043','34048','3
4050','34051','34053','34055','34067','34068','34076','34078','34082','34090','3
4092','34093','34099','34100','34102','34103','34105','34108','34110','34111','3
4112','34113','34120','34132','36002','36003','36014','36016','36030','36035','3
6041','36046','36048','36050','36053','36058','36067','36072','36075','36080','3
6081','36086','36092','36112','36123','36131','36132','36140','36146','36147','3
6149','36157','36159','36162','36163','36164','36165','36168','36169','36170','3
6180','36182','36190','36191','36194','36202','36204','36207','36214','36216','3
6220','36231','36233','36246','36256','36258','36259','36262','36264','36267','3
6268','36273','36275','36277','36299','36300','36302','36306','36310','36321','3
6322','36334','36338','36507','36508','36512','36514','36515','36516','36805','3
6806','36814','36815','36826','36828','36832','36833','36837','36839','36840','3
6841','37000','37002','37008','37009','37010','37011','37012','37013','37014','3
7017','37018','37020','37024','37025','37028','37034','37035','37044','37047','3
7051','37052','37058','37059','37065','37069','37070','39302','39303','39309','3
9312','39324','39326','39327','39329','39338','39339','39340','39342','39344','3
9345','39346','39347','39354','39360','39363','39364','39365','39369','39371','3
9382','39386','39393','39401','39408','39409','39419','39420','39427','39430','3
9433','39445','39446','39450','39455','39456','39462','39477','39478','39480','3
9491','39496','39499','40007','40011','40013','40019','40020','40021','40030','4
0036','40037','40038','40040','40041','40042','40043','40044','40045','40046','4
0047','40048','40049','40050','40054','40063','40064','40068','40073','41001','4
1003','41004','42006','42017','42022','42024','42029','42030','42033','42043','4
2046','42054','42057','42059','42060','42064','42065','42069','42073','42076','4
2077','42085','42089','42092','42095','42098','42104','42113','42117','42119','4
2127','42141','42153','42158','42160','45002','45005','45006','45007','45009','4
5010','45012','45015','45019','45025','45026','45027','45028','45033','45034','4
5036','47004','47005','47007','47011','47012','47017','47018','47021','48002','4
8018','48019','48021','48027','48028','48034','48041','48042','48045','48051','4
8052','48061','48069','48071','48072','48075','48079','48080','48081','48082','4
8101','48104','48117','48118','48126','48129','48131','48138','48139','48140','4
8141','48146','48147','48149','48152','48156','48157','48160','48164','48166','4
8169','48170','48176','48178','48181','48182','48184','48185','48188','48197','4
8205','48206','48208','48220','48225','48232','48236','48237','48244','48248','4
8249','48250','48255','48258','48262','48263','48265','48268','48270','48279','4
8282','48283','48290','48294','48295','48307','48308','48311','48312','48314','4
8319','48322','48325','48329','48336','48339','48342','48343','48344','48346','4
8347','48349','48352','48358','48359','48360','48361','48362','48372','48373','4
8381','48386','48400','48401','48412','48413','48417','48419','48422','48423','4
8437','48438','48440','48441','48451','48452','48454','48458','48459','48462','4
8464','48469','48480','48482','48484','48493','48498','48500','48902','48909','4
8914','48926','48928','48930','48931','49008','49011','49012','49013','49014','4
9018','49020','49023','49035','49041','49042','49043','49051','49053','49054','4
9057','50001','50002','50003','50006','51007','51008','51009','51012','51013','5
1017','51019','51022','51023','51024','51031','51032','51036','51037','51040','5
1042','51043','51044','51046','51047','51048','51057','51059','51061','52003','5
2004','52006','52008','52010','52012','54003','54005','54006','54008','54011','5
5002','55008','55012','55015','55017','55018','55020','55021','55022','55025','5
5033','55704','55709','55710','55721','55722','55723','55724','90006','90007','9
0026','90027','90030','90031','90034','90035','90038','90043','90078','90081','9
0082','90093','90094','90101','90105','90151','90153','90154','90157','90159','9
0166','90167','90186','90188','90192','90193','90232','90233','90264','90301','9
0305','90307','90309','90313','90315','90317','90318','90319','90323','90327','9
0329','90330','90331','90332','90336','90337','90338','90340','90343','90348','9
0350','90351','90354','90355','90358','90359','90360','90361','90366','90369','9
0371','90373','90376','90378','90379','90380','90385','90386','90388','90389','9
0394','90395','90396','90428','90430','90432','90433','90435','90437','90438','9
0439','90440','90441','90442','90478','90502','90504','90514','90521','90522','9
0523','90529','90531','90533','90535','90536','90538','90539','90541','90544','9
0549','90561','90576','90577','90580','90583','90590','90591','90593','90602','9
0604','90605','90612','90653','90686','90702','90704','90726','90803','90806','9
0808','91001','91006','91008','91009','91190','91222','91223','91224','91236','9
1255','91262','91269','91270','91271','91274','91281','91282','91303','91304','9
1322','91324','91325','91326','91352','91353','91354','91355','91426','91428','9
1429','91437','91442','91444','91449','91451','91458','91477','91478','91576','9
1577','91578','91603','91604','91605','91608','91611','91612','91614','91616','9
1617','91620','91652','91653','91654','91676','91701','91705','91707','91708','9
1726','91826','91833','91901','91907','91929','91931','91932','91933','91936','9
1951','91952','91954','91955','91957','91958','91961','91962','91964','91965','9
1966','91967','91969','91971','92027','92028','92102','92103','92113','92115','9
2117','92120','92121','92122','92124','92209','92215','92226','92252','92274','9
2275','92280','92281','92294','92295','92299','92305','92306','92307','92427','9
2428','92452','92453','92457','92459','92461','92462','92470','92475','92489','9
2491','92493','92494','92495','92496','92506','92508','92509','92510','92511','9
2512','92513','92514','92515','92517','92518','92520','92523','92524','92531','9
2532','92554','92555','92556','92559','92562','92563','92564','92565','92566','9
2568','92569','92572','92576','92577','92579','92581','92582','92583','92584','9
2588','92590','92591','92593','92594','92597','92598','92600','92601','92604','9
2605','92606','92609','92611','92613','92617','92618','92623','92624','92626','9
2628','92629','92632','92634','92637','92638','92640','92641','92642','92643','9
2647','92649','92656','92684','92750','92751','92754','92755','92756','92757','9
2758','92760','92762','92763','92764','92767','92769','92772','92776','92778','9
2779','92782','92783','92785','92801','92803','92804','92807','92813','92814','9
2816','92817','92818','92819','92823','92825','92827','92829','92830','92831','9
2835','92836','94000','94026','94027','94028','94029','94031','94032','94035','9
4036','94041','94042','94043','94044','94045','94046','94047','94048','94061','9
4063','94099','94100','94102','94104','94109','94126','94130','94240','94241','9
5056','95058','95061','95062','95063','95078','95083','95084','95087','95104','9
5150','95156','95157','95158','95160','95163','95164','95208','95209','95229','9
5325','95326','95329','95330','95331','95332','95334','95335','95336','95337','9
5340','95341','95344','95345','95346','95347','95348','95349','95390','95391','9
5392','95393','95394','95395','95396','95397','95398','95401','95428','95429','9
5576','95612','95651','95652','95681','95727','95728','95801','95826','95827','9
5828','95852','96076','96078','96079','96115','97038','97039','97076','97176','9
7178','97179','97180','97201','97276','97279','97280','37072','39500','90957','2
2073','94245','95653','51064','51065','92463','12396','48933','48934','36854','2
6182','48936','55726','17393','40075','09050','37074','18589','48937','48938','0
8108','04070','32041','06854','06855','48941','17395','26183','06856','28027','0
1029','22074','39504','48942','48945','48946','34133','42205','12397','01030','2
1414','06859','26185','06860','06861','26186','17102','17101','49062','95926','1
3199','04071','04072','04073','95389','95388','26188','48950','22079','29174','4
8954','97204','12398','06866','06865','06864','06870','48958','48959','12401','1
2402','36856','08114','48963','48961','48960','55046','55048','55051','55052','5
5053','55059','17404','42208','42209','51071','51073','24132','95387','49063','0
6873','08115','34136','06874','21415','27041','39505','13202','52015','06877','1
3205','13204','08117','48507','39506','36523','36522','12405','12404','06878','0
6879','06881','95385','92665','29175','17412','39508','48970','39512','04074','2
6189','13217','13215','94247','06885','41009','41008','49066','29176','42212','2
5083','49067','48509','48512','08120','95374','04075','12406','32048','32046','3
2045','04076','04077','09052','36858','08121','06896','06898','48972','26190','5
5730','39514','08126','40079','17430','26192','39516','17426','17433','04080','4
9069','48523','15009','15010','06748','29177','20039','20040','37079','37080','0
1033','08134','48528','48530','06217','39517','09054','09055','34142','37081','3
4147','34143','47028','49071','49072','52018','52019','52024','52027','41015','4
1017','48984','32052','04082','04083','04084','06612','06616','06620','06623','0
6630','10003','12415','12411','37082','04091','04092','18592','17442','06637','0
6645','52828','52835','52838','47029','40083','48987','48990','26193','36863','3
4151','34150','34149','52028','41025','41027','41028','41029','52030','52031','5
2050','52051','52055','06650','06654','36350','36351','36866','26195','48995','4
2162','42165','42166','13223','12424','48536','29193','40084','31061','06661','5
2066','06667','06668','06670','06676','06677','06679','06680','06682','06686','0
6687','06688','39519','37089','24148','29197','26196','06691','06694','34153','1
3224','02513','55735','34154','52074','52076','41045','52079','52083','41050','4
1051','52084','41054','52088','52090','52091','41055','41057','41060','41064','4
1065','41071','41072','42224','42225','48565','12427','52839','02518','26199','2
6200','12430','12431','42227','48567','17461','02521','02524','02527','02530','0
2533','52843','52842','45061','24149','52093','39524','08144','12441','36354','1
2442','12443','42232','26202','02539','04100','04102','18598','02544','18600','1
3232','13234','09060','25096','29199','37093','39527','34158','39528','04103','0
2549','02553','02555','02559','49076','49077','52096','52104','40087','40090','3
4159','34161','36540','02563','42233','02564','12450','01036','42236','37096','4
2169','02566','02568','52116','39533','02575','04106','39535','51082','37098','4
5068','02583','45070','45071','12452','02588','02589','48579','34164','42239','9
0978','52118','41085','41086','12462','12464','02591','02595','41087','41088','4
1089','02599','02600','12468','02606','02609','41092','40093','48581','48582','9
2437','52121','52122','42246','21433','27045','55739','17483','39537','34170','1
2473','04109','12474','02614','25101','09064','22088','02617','42248','36546','2
1435','41096','52124','52125','49082','54017','42249','41097','04115','26215','4
8589','26216','12476','26218','26217','39539','41099','42254','34175','37102','1
7488','41052','41062','26220','26221','04065','06475','08045','17029','21008','2
6072','29125','36178','48203','48217','95386','97281','49083','49084','48591','4
8592','20044','04116','31066','47034','26223','25106','22090','42172','48595','3
1067','17103','49085','12479','41100','48596','04117','12480','12481','34178','5
2129','37105','51088','01025','04041','06309','06434','06499','06515','06540','0
6552','06566','06709','06843','08008','12043','12092','12116','12142','12202','1
2234','12278','12314','12351','13130','13152','13194','17036','17077','17226','1
7260','18575','21015','22041','23012','25010','25068','26030','26157','26173','2
7017','29134','31042','34096','34107','36064','36181','36199','36218','36232','3
7042','39310','39335','39392','39406','39415','40022','42081','48151','48172','4
8253','48301','48315','48340','48429','48448','48485','51016','51038','55715','9
0162','90349','90362','90431','91956','92109','92289','92472','92497','92560','9
2578','92599','92620','92636','92781','94033','94108','95333','95611','26184','1
2403','49064','17415','32047','36860','06621','39518','12420','25088','12423','1
3222','18594','51075','06692','52082','39522','17466','37101','12458','04113','1
2486','12484','51090','51091','04119','12487','42177','37107','39540','39541','4
8600','52845','12488','26226','10005','12489','02646','92943','28030','02649','0
2650','31068','29214','29211','26227','34185','39545','39546','39547','12490','1
2491','26229','34186','51092','48603','42180','41104','02654','12493','15013','3
2062','32064','32065','02658','91648','18612','18613','55062','42181','40098','0
2659','91647','34190','12495','12496','48606','02662','92889','41105','18615','3
4192','52134','52135','48608','12497','12498','42183','40101','40100','22093','0
4122','04123','04124','02672','48613','12500','04126','48615','17109','02675','3
4194','02678','13242','95097','15014','26230','54023','32066','12502','02682','0
2681','02680','48617','08152','40102','27046','26232','02684','91665','40103','9
2948','37109','02687','04127','48619','02688','48620','22095','08153','12504','3
7111','34195','95456','12506','02691','15015','04128','12509','12510','26233','3
9550','91646','04130','04132','49091','55064','08154','31070','26236','26235','3
9551','55065','02695','34198','34199','48626','01045','02697','12514','47035','4
8628','48629','22096','39554','39552','34200','34203','47036','40104','12517','3
2067','27048','01050','39556','39557','39559','06904','55067','13245','39561','4
8631','50007','36377','45076','90209','48632','48633','13247','48634','29218','4
9093','27049','27053','27054','34205','51098','12520','02704','37114','36384','1
2521','17116','21019','19059','29222','42266','36389','12522','12524','54025','2
6238','92892','48637','48638','22097','22098','08156','08158','02713','13249','4
5078','40105','23026','17117','18623','18624','37117','02715','02716','52144','3
7118','13250','04136','52847','02721','37221','24171','40106','48701','39570','2
6240','25116','13253','13252','37234','37233','17371','45083','13256','42275','3
9576','12530','18629','36550','47042','12531','51100','51102','51103','13259','5
2145','40107','40108','40109','02728','02731','02732','12532','12533','39577','3
7235','32068','52848','48656','04139','48660','36561','48670','13263','15016','1
3264','26250','45090','06908','39574','13265','08160','45091','48668','26247','0
6910','42291','37225','06909','51104','08161','13266','12537','51105','29225','2
9226','12528','48675','49096','22102','22103','04140','04141','27081','55074','3
6576','37236','47046','29227','36936','18636','18637','36393','36394','26255','2
4180','51107','39586','12539','12540','12541','13267','42296','34224','18638','0
6915','02737','02738','47049','37245','91645','15017','04142','13268','41116','1
3269','51108','25121','12542','25123','17496','47050','32069','47051','40111','0
4143','22106','23027','92992','42300','41118','52152','37246','12543','12544','1
3272','23028','48707','48710','51109','08163','06918','55076','12546','50009','5
2849','52850','45099','32070','48672','36938','36939','37247','21441','48669','0
8164','45085','36940','39588','55740','52851','08165','36941','13273','12557','4
2302','12559','06927','39590','36942','36943','04144','04145','26258','29228','4
7053','12561','37250','55741','92993','29229','02739','90982','48715','02743','1
2562','37251','52852','37252','01064','02745','02746','08166','48690','42310','4
5103','28031','49100','08168','12564','08167','49101','49103','36946','12565','3
7253','37254','52854','04149','92996','01065','08174','02751','17501','28032','2
8033','36947','06971','33028','12567','37272','55742','48693','36949','22110','4
0116','52858','08175','06931','32071','09071','48718','29231','13275','04150','3
6959','50010','12571','04151','04152','04153','02756','48899','32075','48736','0
2776','55745','52147','02777','25129','54030','04156','42314','51123','41120','3
2076','25132','08181','08182','48697','92899','32077','32078','02781','48698','3
4231','25133','25134','48737','06981','41121')
and bu_id not in (
select distinct a.bu_id from compass_01_wh..f_gen_sales_dest_bu_day as a (noloc
k)
right outer join
compass_01_wh..loc_bu as b (nolock)
on
a.bu_id=b.bu_id and
b.active ='y' and b.name in ('04008','04015','04016','04017','04
018','04021','04022','04023','01018','01019','01021','04003','01002','01003','01
006','01010','01011','01012','01013','04028','04030','04031','04032','04033','04
036','04038','04040','04042','04049','04050','04051','04052','04053','04054','04
055','04057','04058','04059','04061','04062','04064','04067','04069','06001','06
032','06036','06038','06053','06058','06059','06060','06066','06067','06068','06
073','06075','06083','06087','06094','06095','06098','06099','06100','06113','06
117','06118','06120','06122','06129','06145','06149','06151','06160','06163','06
175','06176','06178','06179','06182','06189','06191','06192','06200','06202','06
205','06207','06209','06219','06220','06222','06224','06236','06238','06239','06
245','06248','06250','06253','06255','06262','06265','06266','06268','06270','06
272','06276','06282','06288','06293','06294','06295','06298','06300','06301','06
303','06313','06315','06316','06317','06319','06320','06321','06322','06323','06
324','06325','06326','06328','06329','06333','06334','06336','06338','06343','06
344','06346','06347','06349','06351','06354','06357','06358','06359','06362','06
363','06381','06383','06385','06387','06389','06390','06391','06392','06394','06
395','06396','06398','06405','06410','06411','06416','06425','06426','06428','06
430','06431','06433','06438','06440','06441','06442','06449','06451','06454','06
455','06461','06463','06466','06467','06470','06472','06473','06477','06479','06
480','06485','06486','06489','06490','06492','06502','06503','06505','06506','06
508','06511','06513','06517','06522','06525','06530','06534','06542','06549','06
555','06556','06560','06562','06568','06569','06571','06572','06574','06580','06
581','06582','06584','06588','06592','06593','06595','06704','06707','06717','06
721','06722','06725','06727','06729','06731','06734','06735','06742','06755','06
764','06768','06772','06785','06790','06791','06792','06794','06804','06808','06
811','06814','06828','06835','06841','06845','06846','06848','06850','08001','08
002','08004','08005','08006','08009','08025','08028','08030','08031','08033','08
034','08039','08042','08043','08046','08052','08054','08064','08067','08068','08
071','08076','08080','08081','08082','08083','08085','08090','08099','08101','08
103','09003','09013','09014','09015','09019','09022','09025','09026','09027','09
031','09036','12002','12005','12008','12009','12013','12014','12016','12017','12
019','12022','12025','12027','12029','12030','12033','12034','12036','12040','12
042','12046','12049','12054','12055','12057','12061','12062','12066','12071','12
074','12078','12081','12085','12089','12091','12095','12103','12111','12113','12
114','12115','12121','12127','12132','12135','12138','12148','12149','12152','12
153','12164','12165','12166','12167','12168','12172','12173','12176','12177','12
182','12184','12185','12186','12187','12190','12195','12196','12198','12199','12
201','12203','12207','12208','12209','12212','12213','12215','12216','12219','12
221','12223','12224','12225','12227','12229','12230','12231','12232','12235','12
237','12238','12240','12241','12242','12244','12247','12257','12261','12266','12
268','12269','12270','12271','12272','12274','12275','12280','12281','12282','12
283','12284','12289','12290','12294','12295','12296','12300','12301','12305','12
306','12312','12318','12320','12323','12325','12329','12333','12334','12336','12
337','12338','12342','12345','12358','12369','12372','12377','12391','12393','13
002','13012','13015','13029','13044','13045','13047','13049','13051','13052','13
055','13056','13059','13067','13068','13070','13071','13077','13079','13082','13
084','13085','13086','13087','13089','13090','13091','13092','13093','13094','13
100','13101','13105','13106','13107','13109','13111','13116','13117','13118','13
119','13123','13125','13128','13129','13146','13150','13154','13165','13170','13
172','13173','13175','13177','13178','13184','15001','15003','15006','17001','17
009','17011','17016','17017','17019','17025','17026','17027','17030','17033','17
034','17039','17046','17048','17053','17054','17063','17071','17205','17206','17
211','17212','17213','17216','17218','17223','17229','17230','17232','17236','17
238','17239','17240','17244','17246','17250','17253','17257','17259','17261','17
263','17268','17275','17278','17281','17282','17291','17293','17294','17296','17
298','17307','17311','17318','17325','17327','17328','17329','17330','17334','17
335','17336','17340','17341','17343','17346','17350','17353','17354','17356','17
359','17362','17364','17365','17366','17368','17370','17388','18511','18519','18
527','18528','18540','18541','18545','18549','18550','18551','18552','18553','18
559','18560','18562','18567','18568','18569','18572','18574','18577','18578','18
579','18584','18585','19003','19004','19008','19010','19011','19016','19022','19
023','19024','19025','19026','19028','19029','19030','19031','19032','19033','20
003','20014','20016','20023','20027','20029','20031','20033','21002','21003','21
005','21006','21007','21013','21401','21402','21404','21408','21410','22009','22
010','22011','22012','22013','22020','22027','22029','22030','22032','22033','22
034','22035','22037','22039','22040','22043','22046','22048','22049','22052','22
056','22057','22065','22066','22068','23010','23013','24009','24021','24073','24
076','24082','24083','24084','24092','24100','24101','24110','24111','24124','24
127','25001','25009','25011','25020','25026','25028','25029','25033','25038','25
053','25058','25069','25070','25071','25072','25078','26002','26007','26008','26
009','26012','26013','26014','26019','26025','26028','26029','26031','26032','26
033','26039','26043','26046','26047','26052','26053','26055','26056','26062','26
063','26066','26073','26074','26075','26079','26084','26085','26086','26088','26
089','26092','26094','26100','26101','26102','26105','26106','26109','26110','26
111','26112','26113','26122','26123','26124','26127','26128','26130','26142','26
143','26144','26148','26149','26152','26154','26156','26158','26159','26176','26
178','26181','27004','27008','27012','27014','27016','27023','27024','27025','27
037','28002','28003','28008','28018','28020','28025','28026','29003','29014','29
015','29026','29028','29029','29031','29037','29040','29041','29042','29043','29
048','29055','29063','29071','29072','29075','29076','29081','29083','29086','29
088','29091','29092','29094','29096','29098','29104','29118','29120','29121','29
123','29127','29129','29138','29140','29141','29142','29143','29147','29156','29
158','29159','29161','29162','31007','31014','31029','31035','31041','31043','31
045','31046','31051','31053','31055','32017','32020','32022','32023','32025','32
026','32028','32030','32034','32035','32038','33004','33006','33008','33009','33
010','33011','33017','34002','34008','34015','34024','34030','34035','34037','34
043','34048','34050','34051','34053','34055','34067','34068','34076','34078','34
082','34090','34092','34093','34099','34100','34102','34103','34105','34108','34
110','34111','34112','34113','34120','34132','36002','36003','36014','36016','36
030','36035','36041','36046','36048','36050','36053','36058','36067','36072','36
075','36080','36081','36086','36092','36112','36123','36131','36132','36140','36
146','36147','36149','36157','36159','36162','36163','36164','36165','36168','36
169','36170','36180','36182','36190','36191','36194','36202','36204','36207','36
214','36216','36220','36231','36233','36246','36256','36258','36259','36262','36
264','36267','36268','36273','36275','36277','36299','36300','36302','36306','36
310','36321','36322','36334','36338','36507','36508','36512','36514','36515','36
516','36805','36806','36814','36815','36826','36828','36832','36833','36837','36
839','36840','36841','37000','37002','37008','37009','37010','37011','37012','37
013','37014','37017','37018','37020','37024','37025','37028','37034','37035','37
044','37047','37051','37052','37058','37059','37065','37069','37070','39302','39
303','39309','39312','39324','39326','39327','39329','39338','39339','39340','39
342','39344','39345','39346','39347','39354','39360','39363','39364','39365','39
369','39371','39382','39386','39393','39401','39408','39409','39419','39420','39
427','39430','39433','39445','39446','39450','39455','39456','39462','39477','39
478','39480','39491','39496','39499','40007','40011','40013','40019','40020','40
021','40030','40036','40037','40038','40040','40041','40042','40043','40044','40
045','40046','40047','40048','40049','40050','40054','40063','40064','40068','40
073','41001','41003','41004','42006','42017','42022','42024','42029','42030','42
033','42043','42046','42054','42057','42059','42060','42064','42065','42069','42
073','42076','42077','42085','42089','42092','42095','42098','42104','42113','42
117','42119','42127','42141','42153','42158','42160','45002','45005','45006','45
007','45009','45010','45012','45015','45019','45025','45026','45027','45028','45
033','45034','45036','47004','47005','47007','47011','47012','47017','47018','47
021','48002','48018','48019','48021','48027','48028','48034','48041','48042','48
045','48051','48052','48061','48069','48071','48072','48075','48079','48080','48
081','48082','48101','48104','48117','48118','48126','48129','48131','48138','48
139','48140','48141','48146','48147','48149','48152','48156','48157','48160','48
164','48166','48169','48170','48176','48178','48181','48182','48184','48185','48
188','48197','48205','48206','48208','48220','48225','48232','48236','48237','48
244','48248','48249','48250','48255','48258','48262','48263','48265','48268','48
270','48279','48282','48283','48290','48294','48295','48307','48308','48311','48
312','48314','48319','48322','48325','48329','48336','48339','48342','48343','48
344','48346','48347','48349','48352','48358','48359','48360','48361','48362','48
372','48373','48381','48386','48400','48401','48412','48413','48417','48419','48
422','48423','48437','48438','48440','48441','48451','48452','48454','48458','48
459','48462','48464','48469','48480','48482','48484','48493','48498','48500','48
902','48909','48914','48926','48928','48930','48931','49008','49011','49012','49
013','49014','49018','49020','49023','49035','49041','49042','49043','49051','49
053','49054','49057','50001','50002','50003','50006','51007','51008','51009','51
012','51013','51017','51019','51022','51023','51024','51031','51032','51036','51
037','51040','51042','51043','51044','51046','51047','51048','51057','51059','51
061','52003','52004','52006','52008','52010','52012','54003','54005','54006','54
008','54011','55002','55008','55012','55015','55017','55018','55020','55021','55
022','55025','55033','55704','55709','55710','55721','55722','55723','55724','90
006','90007','90026','90027','90030','90031','90034','90035','90038','90043','90
078','90081','90082','90093','90094','90101','90105','90151','90153','90154','90
157','90159','90166','90167','90186','90188','90192','90193','90232','90233','90
264','90301','90305','90307','90309','90313','90315','90317','90318','90319','90
323','90327','90329','90330','90331','90332','90336','90337','90338','90340','90
343','90348','90350','90351','90354','90355','90358','90359','90360','90361','90
366','90369','90371','90373','90376','90378','90379','90380','90385','90386','90
388','90389','90394','90395','90396','90428','90430','90432','90433','90435','90
437','90438','90439','90440','90441','90442','90478','90502','90504','90514','90
521','90522','90523','90529','90531','90533','90535','90536','90538','90539','90
541','90544','90549','90561','90576','90577','90580','90583','90590','90591','90
593','90602','90604','90605','90612','90653','90686','90702','90704','90726','90
803','90806','90808','91001','91006','91008','91009','91190','91222','91223','91
224','91236','91255','91262','91269','91270','91271','91274','91281','91282','91
303','91304','91322','91324','91325','91326','91352','91353','91354','91355','91
426','91428','91429','91437','91442','91444','91449','91451','91458','91477','91
478','91576','91577','91578','91603','91604','91605','91608','91611','91612','91
614','91616','91617','91620','91652','91653','91654','91676','91701','91705','91
707','91708','91726','91826','91833','91901','91907','91929','91931','91932','91
933','91936','91951','91952','91954','91955','91957','91958','91961','91962','91
964','91965','91966','91967','91969','91971','92027','92028','92102','92103','92
113','92115','92117','92120','92121','92122','92124','92209','92215','92226','92
252','92274','92275','92280','92281','92294','92295','92299','92305','92306','92
307','92427','92428','92452','92453','92457','92459','92461','92462','92470','92
475','92489','92491','92493','92494','92495','92496','92506','92508','92509','92
510','92511','92512','92513','92514','92515','92517','92518','92520','92523','92
524','92531','92532','92554','92555','92556','92559','92562','92563','92564','92
565','92566','92568','92569','92572','92576','92577','92579','92581','92582','92
583','92584','92588','92590','92591','92593','92594','92597','92598','92600','92
601','92604','92605','92606','92609','92611','92613','92617','92618','92623','92
624','92626','92628','92629','92632','92634','92637','92638','92640','92641','92
642','92643','92647','92649','92656','92684','92750','92751','92754','92755','92
756','92757','92758','92760','92762','92763','92764','92767','92769','92772','92
776','92778','92779','92782','92783','92785','92801','92803','92804','92807','92
813','92814','92816','92817','92818','92819','92823','92825','92827','92829','92
830','92831','92835','92836','94000','94026','94027','94028','94029','94031','94
032','94035','94036','94041','94042','94043','94044','94045','94046','94047','94
048','94061','94063','94099','94100','94102','94104','94109','94126','94130','94
240','94241','95056','95058','95061','95062','95063','95078','95083','95084','95
087','95104','95150','95156','95157','95158','95160','95163','95164','95208','95
209','95229','95325','95326','95329','95330','95331','95332','95334','95335','95
336','95337','95340','95341','95344','95345','95346','95347','95348','95349','95
390','95391','95392','95393','95394','95395','95396','95397','95398','95401','95
428','95429','95576','95612','95651','95652','95681','95727','95728','95801','95
826','95827','95828','95852','96076','96078','96079','96115','97038','97039','97
076','97176','97178','97179','97180','97201','97276','97279','97280','37072','39
500','90957','22073','94245','95653','51064','51065','92463','12396','48933','48
934','36854','26182','48936','55726','17393','40075','09050','37074','18589','48
937','48938','08108','04070','32041','06854','06855','48941','17395','26183','06
856','28027','01029','22074','39504','48942','48945','48946','34133','42205','12
397','01030','21414','06859','26185','06860','06861','26186','17102','17101','49
062','95926','13199','04071','04072','04073','95389','95388','26188','48950','22
079','29174','48954','97204','12398','06866','06865','06864','06870','48958','48
959','12401','12402','36856','08114','48963','48961','48960','55046','55048','55
051','55052','55053','55059','17404','42208','42209','51071','51073','24132','95
387','49063','06873','08115','34136','06874','21415','27041','39505','13202','52
015','06877','13205','13204','08117','48507','39506','36523','36522','12405','12
404','06878','06879','06881','95385','92665','29175','17412','39508','48970','39
512','04074','26189','13217','13215','94247','06885','41009','41008','49066','29
176','42212','25083','49067','48509','48512','08120','95374','04075','12406','32
048','32046','32045','04076','04077','09052','36858','08121','06896','06898','48
972','26190','55730','39514','08126','40079','17430','26192','39516','17426','17
433','04080','49069','48523','15009','15010','06748','29177','20039','20040','37
079','37080','01033','08134','48528','48530','06217','39517','09054','09055','34
142','37081','34147','34143','47028','49071','49072','52018','52019','52024','52
027','41015','41017','48984','32052','04082','04083','04084','06612','06616','06
620','06623','06630','10003','12415','12411','37082','04091','04092','18592','17
442','06637','06645','52828','52835','52838','47029','40083','48987','48990','26
193','36863','34151','34150','34149','52028','41025','41027','41028','41029','52
030','52031','52050','52051','52055','06650','06654','36350','36351','36866','26
195','48995','42162','42165','42166','13223','12424','48536','29193','40084','31
061','06661','52066','06667','06668','06670','06676','06677','06679','06680','06
682','06686','06687','06688','39519','37089','24148','29197','26196','06691','06
694','34153','13224','02513','55735','34154','52074','52076','41045','52079','52
083','41050','41051','52084','41054','52088','52090','52091','41055','41057','41
060','41064','41065','41071','41072','42224','42225','48565','12427','52839','02
518','26199','26200','12430','12431','42227','48567','17461','02521','02524','02
527','02530','02533','52843','52842','45061','24149','52093','39524','08144','12
441','36354','12442','12443','42232','26202','02539','04100','04102','18598','02
544','18600','13232','13234','09060','25096','29199','37093','39527','34158','39
528','04103','02549','02553','02555','02559','49076','49077','52096','52104','40
087','40090','34159','34161','36540','02563','42233','02564','12450','01036','42
236','37096','42169','02566','02568','52116','39533','02575','04106','39535','51
082','37098','45068','02583','45070','45071','12452','02588','02589','48579','34
164','42239','90978','52118','41085','41086','12462','12464','02591','02595','41
087','41088','41089','02599','02600','12468','02606','02609','41092','40093','48
581','48582','92437','52121','52122','42246','21433','27045','55739','17483','39
537','34170','12473','04109','12474','02614','25101','09064','22088','02617','42
248','36546','21435','41096','52124','52125','49082','54017','42249','41097','04
115','26215','48589','26216','12476','26218','26217','39539','41099','42254','34
175','37102','17488','41052','41062','26220','26221','04065','06475','08045','17
029','21008','26072','29125','36178','48203','48217','95386','97281','49083','49
084','48591','48592','20044','04116','31066','47034','26223','25106','22090','42
172','48595','31067','17103','49085','12479','41100','48596','04117','12480','12
481','34178','52129','37105','51088','01025','04041','06309','06434','06499','06
515','06540','06552','06566','06709','06843','08008','12043','12092','12116','12
142','12202','12234','12278','12314','12351','13130','13152','13194','17036','17
077','17226','17260','18575','21015','22041','23012','25010','25068','26030','26
157','26173','27017','29134','31042','34096','34107','36064','36181','36199','36
218','36232','37042','39310','39335','39392','39406','39415','40022','42081','48
151','48172','48253','48301','48315','48340','48429','48448','48485','51016','51
038','55715','90162','90349','90362','90431','91956','92109','92289','92472','92
497','92560','92578','92599','92620','92636','92781','94033','94108','95333','95
611','26184','12403','49064','17415','32047','36860','06621','39518','12420','25
088','12423','13222','18594','51075','06692','52082','39522','17466','37101','12
458','04113','12486','12484','51090','51091','04119','12487','42177','37107','39
540','39541','48600','52845','12488','26226','10005','12489','02646','92943','28
030','02649','02650','31068','29214','29211','26227','34185','39545','39546','39
547','12490','12491','26229','34186','51092','48603','42180','41104','02654','12
493','15013','32062','32064','32065','02658','91648','18612','18613','55062','42
181','40098','02659','91647','34190','12495','12496','48606','02662','92889','41
105','18615','34192','52134','52135','48608','12497','12498','42183','40101','40
100','22093','04122','04123','04124','02672','48613','12500','04126','48615','17
109','02675','34194','02678','13242','95097','15014','26230','54023','32066','12
502','02682','02681','02680','48617','08152','40102','27046','26232','02684','91
665','40103','92948','37109','02687','04127','48619','02688','48620','22095','08
153','12504','37111','34195','95456','12506','02691','15015','04128','12509','12
510','26233','39550','91646','04130','04132','49091','55064','08154','31070','26
236','26235','39551','55065','02695','34198','34199','48626','01045','02697','12
514','47035','48628','48629','22096','39554','39552','34200','34203','47036','40
104','12517','32067','27048','01050','39556','39557','39559','06904','55067','13
245','39561','48631','50007','36377','45076','90209','48632','48633','13247','48
634','29218','49093','27049','27053','27054','34205','51098','12520','02704','37
114','36384','12521','17116','21019','19059','29222','42266','36389','12522','12
524','54025','26238','92892','48637','48638','22097','22098','08156','08158','02
713','13249','45078','40105','23026','17117','18623','18624','37117','02715','02
716','52144','37118','13250','04136','52847','02721','37221','24171','40106','48
701','39570','26240','25116','13253','13252','37234','37233','17371','45083','13
256','42275','39576','12530','18629','36550','47042','12531','51100','51102','51
103','13259','52145','40107','40108','40109','02728','02731','02732','12532','12
533','39577','37235','32068','52848','48656','04139','48660','36561','48670','13
263','15016','13264','26250','45090','06908','39574','13265','08160','45091','48
668','26247','06910','42291','37225','06909','51104','08161','13266','12537','51
105','29225','29226','12528','48675','49096','22102','22103','04140','04141','27
081','55074','36576','37236','47046','29227','36936','18636','18637','36393','36
394','26255','24180','51107','39586','12539','12540','12541','13267','42296','34
224','18638','06915','02737','02738','47049','37245','91645','15017','04142','13
268','41116','13269','51108','25121','12542','25123','17496','47050','32069','47
051','40111','04143','22106','23027','92992','42300','41118','52152','37246','12
543','12544','13272','23028','48707','48710','51109','08163','06918','55076','12
546','50009','52849','52850','45099','32070','48672','36938','36939','37247','21
441','48669','08164','45085','36940','39588','55740','52851','08165','36941','13
273','12557','42302','12559','06927','39590','36942','36943','04144','04145','26
258','29228','47053','12561','37250','55741','92993','29229','02739','90982','48
715','02743','12562','37251','52852','37252','01064','02745','02746','08166','48
690','42310','45103','28031','49100','08168','12564','08167','49101','49103','36
946','12565','37253','37254','52854','04149','92996','01065','08174','02751','17
501','28032','28033','36947','06971','33028','12567','37272','55742','48693','36
949','22110','40116','52858','08175','06931','32071','09071','48718','29231','13
275','04150','36959','50010','12571','04151','04152','04153','02756','48899','32
075','48736','02776','55745','52147','02777','25129','54030','04156','42314','51
123','41120','32076','25132','08181','08182','48697','92899','32077','32078','02
781','48698','34231','25133','25134','48737','06981','41121')
where a.business_date = convert(varchar(10), getdate()- @iDay,
112)
and a.bu_id is not null))

set @iDay = @iDay - 1


end
select CONVERT(VARCHAR(10),BusinessDate,111) business_date,iCount missing_cpst_c
ount from #MissingCPSTCount order by BusinessDate desc
select CONVERT(VARCHAR(10),BusinessDate,111) business_date,iStore missing_store
from #MissingCPSTStore order by BusinessDate asc
drop table #MissingCPSTCount
drop table #MissingCPSTStore

You might also like