|  | @@ -111,11 +111,14 @@
 | 
	
		
			
				|  |  |          SELECT count(0)                                              as total,
 | 
	
		
			
				|  |  |                 sum(if(oh.org_id is null, 1, 0))                      as unreachedCount,
 | 
	
		
			
				|  |  |                 sum(if(o.type = 4, 1, 0))                             as bankingCount,
 | 
	
		
			
				|  |  | +               sum(if(o.type = 4 and oe.self_service_bank=1, 1, 0))  as onlineATMCount,
 | 
	
		
			
				|  |  |                 sum(if(o.type = 5, 1, 0))                             as offATMCount,
 | 
	
		
			
				|  |  | -               sum(if(o.type = 4, oh.ga382021, 0)) as bankingGA382021,
 | 
	
		
			
				|  |  | -               sum(if(o.type = 4, oh.ga382015, 0)) as bankingGA382015,
 | 
	
		
			
				|  |  | -               sum(if(o.type = 5, oh.ga382021, 0)) as offATMGA382021,
 | 
	
		
			
				|  |  | -               sum(if(o.type = 5, oh.ga382015 , 0)) as offATMGA382015,
 | 
	
		
			
				|  |  | +               sum(if(o.type = 4 and oh.banking2021>0 and oh.banking2021 is not null, 1, 0)) as bankingGA382021,
 | 
	
		
			
				|  |  | +               sum(if(o.type = 4 and oh.banking2015>0 and oh.banking2015 is not null,1, 0)) as bankingGA382015,
 | 
	
		
			
				|  |  | +               sum(if(o.type = 4 and oe.self_service_bank=1 and oh.online2021>0 and oh.online2021 is not null,1, 0)) as onlineGA382021,
 | 
	
		
			
				|  |  | +               sum(if(o.type = 4 and oe.self_service_bank=1 and oh.online2015>0 and oh.online2015 is not null,1, 0)) as onlineGA382015,
 | 
	
		
			
				|  |  | +               sum(if(o.type = 5 and oh.offline2021>0 and oh.offline2021 is not null,1, 0)) as offATMGA382021,
 | 
	
		
			
				|  |  | +               sum(if(o.type = 5 and oh.offline2015>0 and oh.offline2015 is not null,1 , 0)) as offATMGA382015,
 | 
	
		
			
				|  |  |                 sum(oe.business_library_type = 1)           as businessLibraryOne,
 | 
	
		
			
				|  |  |                 sum(oe.business_library_type = 2)           as businessLibraryTwo,
 | 
	
		
			
				|  |  |                 sum(oe.business_library_type = 3)           as businessLibraryThree,
 | 
	
	
		
			
				|  | @@ -126,13 +129,25 @@
 | 
	
		
			
				|  |  |                 sum(if(o.type = 5, oe.lobby_equipment,0))    as offATMObbyDeviceCount,
 | 
	
		
			
				|  |  |                 sum(if(o.type = 5, oe.wall_penetrating_equipment,0))     as offATMWallDeviceCount
 | 
	
		
			
				|  |  |          FROM sys_org o
 | 
	
		
			
				|  |  | -                 LEFT JOIN (SELECT org_id,
 | 
	
		
			
				|  |  | -                                   sum(standard = 1) AS ga382021,
 | 
	
		
			
				|  |  | -                                   sum(standard = 2) AS ga382015
 | 
	
		
			
				|  |  | +                 LEFT JOIN (select org_id,
 | 
	
		
			
				|  |  | +                                   banking2021,
 | 
	
		
			
				|  |  | +                                   if(banking2015>0 and banking2021=0,1,0) as banking2015,
 | 
	
		
			
				|  |  | +                                   if(online2021 >0 or banking2021>0 ,1,0) as online2021,
 | 
	
		
			
				|  |  | +                                   if((online2015>0 or banking2015>0) and online2021=0 and banking2021=0 ,1,0) as  online2015,
 | 
	
		
			
				|  |  | +                                   offline2021,
 | 
	
		
			
				|  |  | +                                   if(offline2015>0 and offline2021=0,1,0) as offline2015
 | 
	
		
			
				|  |  | +                            from (
 | 
	
		
			
				|  |  | +                        SELECT org_id,
 | 
	
		
			
				|  |  | +                                   sum(type=1 and standard = 1) banking2021,
 | 
	
		
			
				|  |  | +                                   sum(type=1 and standard = 2) banking2015,
 | 
	
		
			
				|  |  | +                                   sum(type=2 and standard = 1) online2021,
 | 
	
		
			
				|  |  | +                                   sum(type=2 and standard = 2) online2015,
 | 
	
		
			
				|  |  | +                                   sum(type=3 and standard = 1) offline2021,
 | 
	
		
			
				|  |  | +                                   sum(type=3 and standard = 2) offline2015
 | 
	
		
			
				|  |  |                              FROM sys_org_physical_defense_construction
 | 
	
		
			
				|  |  | -                            WHERE type = 1
 | 
	
		
			
				|  |  | +                            WHERE type = 1 or type=2
 | 
	
		
			
				|  |  |                                 OR type = 3
 | 
	
		
			
				|  |  | -                            GROUP BY org_id) oh ON o.id = oh.org_id
 | 
	
		
			
				|  |  | +                            GROUP BY org_id) t1) oh ON o.id = oh.org_id
 | 
	
		
			
				|  |  |                   LEFT JOIN sys_org_extend oe on o.id = oe.org_id
 | 
	
		
			
				|  |  |          WHERE o.deleted = 0
 | 
	
		
			
				|  |  |            and o.is_lock = 0
 |