<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="BjobBzwkDstcdYearly">
  
  <statement id="selectByEaiBzwdstcdYearly" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
         SELECT                                       
		        SUBSTR(FileTrsmtStartHMS, 1, 4) AS "STATCY"
              , BJ08.BjobBzwkDstcd
              , BJ02.BjobBzwkName                  
		      , SUM(CASE WHEN ThisStgePrcssRsultCd = 'E' THEN 0 ELSE 1 END) AS "YNTRSMTNOITM"   
		      , SUM(CASE WHEN ThisStgePrcssRsultCd = 'E' THEN 1 ELSE 0 END) AS "YNERRNOITM"    
		FROM  $schemaId$.TSEAIBJ08 BJ08, $schemaId$.TSEAIBJ02 BJ02                 
		WHERE BJ08.BjobBzwkDstcd = BJ02.BjobBzwkDstcd
		<isNotEmpty prepend="AND" property="searchEaiBzwkDstcd">
			(  TRIM(BJ08.BjobBzwkDstcd) LIKE CONCAT( '%',CONCAT( UPPER(#searchEaiBzwkDstcd#) , '%') ) OR
				  BJ02.BjobBzwkName LIKE CONCAT( '%',CONCAT( UPPER(#searchEaiBzwkDstcd#) , '%') )   )
		</isNotEmpty>        
		GROUP BY SUBSTR(FileTrsmtStartHMS, 1, 4), BJ08.BjobBzwkDstcd ,BJ02.BjobBzwkName
  </statement>
  
</sqlMap>
