<?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="EaiSvcNameDaily">
  
  <statement id="selectListCount" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
       SELECT COUNT(*) AS "TOTALCOUNT"
       		,  SUM(DDTRSMTNOITM1)    AS "DDTRSMTNOITM1_SUM"
            ,  SUM(DDERRNOITM1)      AS "DDERRNOITM1_SUM"
            ,  SUM(DDTRSMTNOITM2)    AS "DDTRSMTNOITM2_SUM"
            ,  SUM(DDERRNOITM2)      AS "DDERRNOITM2_SUM"
            ,  SUM(DDTRSMTNOITM3)    AS "DDTRSMTNOITM3_SUM"
            ,  SUM(DDERRNOITM3)      AS "DDERRNOITM3_SUM"
            ,  SUM(DDTRSMTNOITM4)    AS "DDTRSMTNOITM4_SUM"
            ,  SUM(DDERRNOITM4)      AS "DDERRNOITM4_SUM"
            ,  SUM(DDTRSMTNOITM5)    AS "DDTRSMTNOITM5_SUM"
            ,  SUM(DDERRNOITM5)      AS "DDERRNOITM5_SUM"
            ,  SUM(DDTRSMTNOITM6)    AS "DDTRSMTNOITM6_SUM"
            ,  SUM(DDERRNOITM6)      AS "DDERRNOITM6_SUM"
            ,  SUM(DDTRSMTNOITM7)    AS "DDTRSMTNOITM7_SUM"
            ,  SUM(DDERRNOITM7)      AS "DDERRNOITM7_SUM"
            ,  SUM(DDTRSMTNOITM8)    AS "DDTRSMTNOITM8_SUM"
            ,  SUM(DDERRNOITM8)      AS "DDERRNOITM8_SUM"
            ,  SUM(DDTRSMTNOITM9)    AS "DDTRSMTNOITM9_SUM"
            ,  SUM(DDERRNOITM9)      AS "DDERRNOITM9_SUM"
            ,  SUM(DDTRSMTNOITM10)   AS "DDTRSMTNOITM10_SUM"
            ,  SUM(DDERRNOITM10)     AS "DDERRNOITM10_SUM"
            ,  SUM(DDTRSMTNOITM11)   AS "DDTRSMTNOITM11_SUM"
            ,  SUM(DDERRNOITM11)     AS "DDERRNOITM11_SUM"
            ,  SUM(DDTRSMTNOITM12)   AS "DDTRSMTNOITM12_SUM"
            ,  SUM(DDERRNOITM12)     AS "DDERRNOITM12_SUM"
            ,  SUM(DDTRSMTNOITM13)   AS "DDTRSMTNOITM13_SUM"
            ,  SUM(DDERRNOITM13)     AS "DDERRNOITM13_SUM"
            ,  SUM(DDTRSMTNOITM14)   AS "DDTRSMTNOITM14_SUM"
            ,  SUM(DDERRNOITM14)     AS "DDERRNOITM14_SUM"
            ,  SUM(DDTRSMTNOITM15)   AS "DDTRSMTNOITM15_SUM"
            ,  SUM(DDERRNOITM15)     AS "DDERRNOITM15_SUM"
            ,  SUM(DDTRSMTNOITM16)   AS "DDTRSMTNOITM16_SUM"
            ,  SUM(DDERRNOITM16)     AS "DDERRNOITM16_SUM"
            ,  SUM(DDTRSMTNOITM17)   AS "DDTRSMTNOITM17_SUM"
            ,  SUM(DDERRNOITM17)     AS "DDERRNOITM17_SUM"
            ,  SUM(DDTRSMTNOITM18)   AS "DDTRSMTNOITM18_SUM"
            ,  SUM(DDERRNOITM18)     AS "DDERRNOITM18_SUM"
            ,  SUM(DDTRSMTNOITM19)   AS "DDTRSMTNOITM19_SUM"
            ,  SUM(DDERRNOITM19)     AS "DDERRNOITM19_SUM"
            ,  SUM(DDTRSMTNOITM20)   AS "DDTRSMTNOITM20_SUM"
            ,  SUM(DDERRNOITM20)     AS "DDERRNOITM20_SUM"
            ,  SUM(DDTRSMTNOITM21)   AS "DDTRSMTNOITM21_SUM"
            ,  SUM(DDERRNOITM21)     AS "DDERRNOITM21_SUM"
            ,  SUM(DDTRSMTNOITM22)   AS "DDTRSMTNOITM22_SUM"
            ,  SUM(DDERRNOITM22)     AS "DDERRNOITM22_SUM"
            ,  SUM(DDTRSMTNOITM23)   AS "DDTRSMTNOITM23_SUM"
            ,  SUM(DDERRNOITM23)     AS "DDERRNOITM23_SUM"
            ,  SUM(DDTRSMTNOITM24)   AS "DDTRSMTNOITM24_SUM"
            ,  SUM(DDERRNOITM24)     AS "DDERRNOITM24_SUM"
            ,  SUM(DDTRSMTNOITM25)   AS "DDTRSMTNOITM25_SUM"
            ,  SUM(DDERRNOITM25)     AS "DDERRNOITM25_SUM"
            ,  SUM(DDTRSMTNOITM26)   AS "DDTRSMTNOITM26_SUM"
            ,  SUM(DDERRNOITM26)     AS "DDERRNOITM26_SUM"
            ,  SUM(DDTRSMTNOITM27)   AS "DDTRSMTNOITM27_SUM"
            ,  SUM(DDERRNOITM27)     AS "DDERRNOITM27_SUM"
            ,  SUM(DDTRSMTNOITM28)   AS "DDTRSMTNOITM28_SUM"
            ,  SUM(DDERRNOITM28)     AS "DDERRNOITM28_SUM"
            ,  SUM(DDTRSMTNOITM29)   AS "DDTRSMTNOITM29_SUM"
            ,  SUM(DDERRNOITM29)     AS "DDERRNOITM29_SUM"
            ,  SUM(DDTRSMTNOITM30)   AS "DDTRSMTNOITM30_SUM"
            ,  SUM(DDERRNOITM30)     AS "DDERRNOITM30_SUM"
            ,  SUM(DDTRSMTNOITM31)   AS "DDTRSMTNOITM31_SUM"
            ,  SUM(DDERRNOITM31)     AS "DDERRNOITM31_SUM"
       FROM ( SELECT EAISVCNAME,
              SUM(S1DDTRSMTNOITM)  AS  DDTRSMTNOITM1, SUM(S1DDERRNOITM)  AS DDERRNOITM1,  SUM(S1DDRSPNSAVGVAL)  AS DDRSPNSAVGVAL1,
              SUM(S2DDTRSMTNOITM)  AS  DDTRSMTNOITM2, SUM(S2DDERRNOITM)  AS DDERRNOITM2,  SUM(S2DDRSPNSAVGVAL)  AS DDRSPNSAVGVAL2,
              SUM(S3DDTRSMTNOITM)  AS  DDTRSMTNOITM3, SUM(S3DDERRNOITM)  AS DDERRNOITM3,  SUM(S3DDRSPNSAVGVAL)  AS DDRSPNSAVGVAL3,
              SUM(S4DDTRSMTNOITM)  AS  DDTRSMTNOITM4, SUM(S4DDERRNOITM)  AS DDERRNOITM4,  SUM(S4DDRSPNSAVGVAL)  AS DDRSPNSAVGVAL4,
              SUM(S5DDTRSMTNOITM)  AS  DDTRSMTNOITM5, SUM(S5DDERRNOITM)  AS DDERRNOITM5,  SUM(S5DDRSPNSAVGVAL)  AS DDRSPNSAVGVAL5,
              SUM(S6DDTRSMTNOITM)  AS  DDTRSMTNOITM6, SUM(S6DDERRNOITM)  AS DDERRNOITM6,  SUM(S6DDRSPNSAVGVAL)  AS DDRSPNSAVGVAL6,
              SUM(S7DDTRSMTNOITM)  AS  DDTRSMTNOITM7, SUM(S7DDERRNOITM)  AS DDERRNOITM7,  SUM(S7DDRSPNSAVGVAL)  AS DDRSPNSAVGVAL7,
              SUM(S8DDTRSMTNOITM)  AS  DDTRSMTNOITM8, SUM(S8DDERRNOITM)  AS DDERRNOITM8,  SUM(S8DDRSPNSAVGVAL)  AS DDRSPNSAVGVAL8,
              SUM(S9DDTRSMTNOITM)  AS  DDTRSMTNOITM9, SUM(S9DDERRNOITM)  AS DDERRNOITM9,  SUM(S9DDRSPNSAVGVAL)  AS DDRSPNSAVGVAL9,
              SUM(S10DDTRSMTNOITM) AS DDTRSMTNOITM10, SUM(S10DDERRNOITM) AS DDERRNOITM10, SUM(S10DDRSPNSAVGVAL) AS DDRSPNSAVGVAL10,
              SUM(S11DDTRSMTNOITM) AS DDTRSMTNOITM11, SUM(S11DDERRNOITM) AS DDERRNOITM11, SUM(S11DDRSPNSAVGVAL) AS DDRSPNSAVGVAL11,
              SUM(S12DDTRSMTNOITM) AS DDTRSMTNOITM12, SUM(S12DDERRNOITM) AS DDERRNOITM12, SUM(S12DDRSPNSAVGVAL) AS DDRSPNSAVGVAL12,
              SUM(S13DDTRSMTNOITM) AS DDTRSMTNOITM13, SUM(S13DDERRNOITM) AS DDERRNOITM13, SUM(S13DDRSPNSAVGVAL) AS DDRSPNSAVGVAL13,
              SUM(S14DDTRSMTNOITM) AS DDTRSMTNOITM14, SUM(S14DDERRNOITM) AS DDERRNOITM14, SUM(S14DDRSPNSAVGVAL) AS DDRSPNSAVGVAL14,
              SUM(S15DDTRSMTNOITM) AS DDTRSMTNOITM15, SUM(S15DDERRNOITM) AS DDERRNOITM15, SUM(S15DDRSPNSAVGVAL) AS DDRSPNSAVGVAL15,
              SUM(S16DDTRSMTNOITM) AS DDTRSMTNOITM16, SUM(S16DDERRNOITM) AS DDERRNOITM16, SUM(S16DDRSPNSAVGVAL) AS DDRSPNSAVGVAL16,
              SUM(S17DDTRSMTNOITM) AS DDTRSMTNOITM17, SUM(S17DDERRNOITM) AS DDERRNOITM17, SUM(S17DDRSPNSAVGVAL) AS DDRSPNSAVGVAL17,
              SUM(S18DDTRSMTNOITM) AS DDTRSMTNOITM18, SUM(S18DDERRNOITM) AS DDERRNOITM18, SUM(S18DDRSPNSAVGVAL) AS DDRSPNSAVGVAL18,
              SUM(S19DDTRSMTNOITM) AS DDTRSMTNOITM19, SUM(S19DDERRNOITM) AS DDERRNOITM19, SUM(S19DDRSPNSAVGVAL) AS DDRSPNSAVGVAL19,
              SUM(S20DDTRSMTNOITM) AS DDTRSMTNOITM20, SUM(S20DDERRNOITM) AS DDERRNOITM20, SUM(S20DDRSPNSAVGVAL) AS DDRSPNSAVGVAL20,
              SUM(S21DDTRSMTNOITM) AS DDTRSMTNOITM21, SUM(S21DDERRNOITM) AS DDERRNOITM21, SUM(S21DDRSPNSAVGVAL) AS DDRSPNSAVGVAL21,
              SUM(S22DDTRSMTNOITM) AS DDTRSMTNOITM22, SUM(S22DDERRNOITM) AS DDERRNOITM22, SUM(S22DDRSPNSAVGVAL) AS DDRSPNSAVGVAL22,
              SUM(S23DDTRSMTNOITM) AS DDTRSMTNOITM23, SUM(S23DDERRNOITM) AS DDERRNOITM23, SUM(S23DDRSPNSAVGVAL) AS DDRSPNSAVGVAL23,
              SUM(S24DDTRSMTNOITM) AS DDTRSMTNOITM24, SUM(S24DDERRNOITM) AS DDERRNOITM24, SUM(S24DDRSPNSAVGVAL) AS DDRSPNSAVGVAL24,
              SUM(S25DDTRSMTNOITM) AS DDTRSMTNOITM25, SUM(S25DDERRNOITM) AS DDERRNOITM25, SUM(S25DDRSPNSAVGVAL) AS DDRSPNSAVGVAL25,
              SUM(S26DDTRSMTNOITM) AS DDTRSMTNOITM26, SUM(S26DDERRNOITM) AS DDERRNOITM26, SUM(S26DDRSPNSAVGVAL) AS DDRSPNSAVGVAL26,
              SUM(S27DDTRSMTNOITM) AS DDTRSMTNOITM27, SUM(S27DDERRNOITM) AS DDERRNOITM27, SUM(S27DDRSPNSAVGVAL) AS DDRSPNSAVGVAL27,
              SUM(S28DDTRSMTNOITM) AS DDTRSMTNOITM28, SUM(S28DDERRNOITM) AS DDERRNOITM28, SUM(S28DDRSPNSAVGVAL) AS DDRSPNSAVGVAL28,
              SUM(S29DDTRSMTNOITM) AS DDTRSMTNOITM29, SUM(S29DDERRNOITM) AS DDERRNOITM29, SUM(S29DDRSPNSAVGVAL) AS DDRSPNSAVGVAL29,
              SUM(S30DDTRSMTNOITM) AS DDTRSMTNOITM30, SUM(S30DDERRNOITM) AS DDERRNOITM30, SUM(S30DDRSPNSAVGVAL) AS DDRSPNSAVGVAL30,
              SUM(S31DDTRSMTNOITM) AS DDTRSMTNOITM31, SUM(S31DDERRNOITM) AS DDERRNOITM31, SUM(S31DDRSPNSAVGVAL) AS DDRSPNSAVGVAL31
         FROM $schemaId$.TSEAIST03
        WHERE STATCYM BETWEEN #searchStart# AND #searchEnd#
        GROUP BY EAISVCNAME
        ORDER BY EAISVCNAME
			) A
			LEFT OUTER JOIN $schemaId$.TSEAIHE01 B
			ON  TRIM(A.EAISVCNAME) = B.EAISVCNAME
			<dynamic prepend="WHERE">
				<isNotEmpty prepend="AND" property="searchEaiBzwkDstcd">
					( TRIM(A.EAISVCNAME) LIKE CONCAT( '%',CONCAT( UPPER(#searchEaiBzwkDstcd#) , '%') ) OR
					  TRIM(B.EAISVCDESC) LIKE CONCAT( '%',CONCAT( UPPER(#searchEaiBzwkDstcd#) , '%') ) )
				</isNotEmpty>
			</dynamic>
   </statement>
  
  <statement id="selectByEaiSvcNameDaily" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
       SELECT A.EAISVCNAME AS "EAISVCNAME", COALESCE(B.EAISVCDESC, 'UNKNOWN') AS "EAISVCDESC",
              SUM(S1DDTRSMTNOITM)  AS "DDTRSMTNOITM1",  SUM(S1DDERRNOITM) AS "DDERRNOITM1",  SUM(S1DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL1",
              SUM(S2DDTRSMTNOITM)  AS "DDTRSMTNOITM2",  SUM(S2DDERRNOITM) AS "DDERRNOITM2",  SUM(S2DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL2",
              SUM(S3DDTRSMTNOITM)  AS "DDTRSMTNOITM3",  SUM(S3DDERRNOITM) AS "DDERRNOITM3",  SUM(S3DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL3",
              SUM(S4DDTRSMTNOITM)  AS "DDTRSMTNOITM4",  SUM(S4DDERRNOITM) AS "DDERRNOITM4",  SUM(S4DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL4",
              SUM(S5DDTRSMTNOITM)  AS "DDTRSMTNOITM5",  SUM(S5DDERRNOITM) AS "DDERRNOITM5",  SUM(S5DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL5",
              SUM(S6DDTRSMTNOITM)  AS "DDTRSMTNOITM6",  SUM(S6DDERRNOITM) AS "DDERRNOITM6",  SUM(S6DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL6",
              SUM(S7DDTRSMTNOITM)  AS "DDTRSMTNOITM7",  SUM(S7DDERRNOITM) AS "DDERRNOITM7",  SUM(S7DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL7",
              SUM(S8DDTRSMTNOITM)  AS "DDTRSMTNOITM8",  SUM(S8DDERRNOITM) AS "DDERRNOITM8",  SUM(S8DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL8",
              SUM(S9DDTRSMTNOITM)  AS "DDTRSMTNOITM9",  SUM(S9DDERRNOITM) AS "DDERRNOITM9",  SUM(S9DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL9",
              SUM(S10DDTRSMTNOITM) AS "DDTRSMTNOITM10", SUM(S10DDERRNOITM) AS "DDERRNOITM10", SUM(S10DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL10",
              SUM(S11DDTRSMTNOITM) AS "DDTRSMTNOITM11", SUM(S11DDERRNOITM) AS "DDERRNOITM11", SUM(S11DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL11",
              SUM(S12DDTRSMTNOITM) AS "DDTRSMTNOITM12", SUM(S12DDERRNOITM) AS "DDERRNOITM12", SUM(S12DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL12",
              SUM(S13DDTRSMTNOITM) AS "DDTRSMTNOITM13", SUM(S13DDERRNOITM) AS "DDERRNOITM13", SUM(S13DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL13",
              SUM(S14DDTRSMTNOITM) AS "DDTRSMTNOITM14", SUM(S14DDERRNOITM) AS "DDERRNOITM14", SUM(S14DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL14",
              SUM(S15DDTRSMTNOITM) AS "DDTRSMTNOITM15", SUM(S15DDERRNOITM) AS "DDERRNOITM15", SUM(S15DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL15",
              SUM(S16DDTRSMTNOITM) AS "DDTRSMTNOITM16", SUM(S16DDERRNOITM) AS "DDERRNOITM16", SUM(S16DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL16",
              SUM(S17DDTRSMTNOITM) AS "DDTRSMTNOITM17", SUM(S17DDERRNOITM) AS "DDERRNOITM17", SUM(S17DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL17",
              SUM(S18DDTRSMTNOITM) AS "DDTRSMTNOITM18", SUM(S18DDERRNOITM) AS "DDERRNOITM18", SUM(S18DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL18",
              SUM(S19DDTRSMTNOITM) AS "DDTRSMTNOITM19", SUM(S19DDERRNOITM) AS "DDERRNOITM19", SUM(S19DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL19",
              SUM(S20DDTRSMTNOITM) AS "DDTRSMTNOITM20", SUM(S20DDERRNOITM) AS "DDERRNOITM20", SUM(S20DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL20",
              SUM(S21DDTRSMTNOITM) AS "DDTRSMTNOITM21", SUM(S21DDERRNOITM) AS "DDERRNOITM21", SUM(S21DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL21",
              SUM(S22DDTRSMTNOITM) AS "DDTRSMTNOITM22", SUM(S22DDERRNOITM) AS "DDERRNOITM22", SUM(S22DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL22",
              SUM(S23DDTRSMTNOITM) AS "DDTRSMTNOITM23", SUM(S23DDERRNOITM) AS "DDERRNOITM23", SUM(S23DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL23",
              SUM(S24DDTRSMTNOITM) AS "DDTRSMTNOITM24", SUM(S24DDERRNOITM) AS "DDERRNOITM24", SUM(S24DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL24",
              SUM(S25DDTRSMTNOITM) AS "DDTRSMTNOITM25", SUM(S25DDERRNOITM) AS "DDERRNOITM25", SUM(S25DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL25",
              SUM(S26DDTRSMTNOITM) AS "DDTRSMTNOITM26", SUM(S26DDERRNOITM) AS "DDERRNOITM26", SUM(S26DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL26",
              SUM(S27DDTRSMTNOITM) AS "DDTRSMTNOITM27", SUM(S27DDERRNOITM) AS "DDERRNOITM27", SUM(S27DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL27",
              SUM(S28DDTRSMTNOITM) AS "DDTRSMTNOITM28", SUM(S28DDERRNOITM) AS "DDERRNOITM28", SUM(S28DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL28",
              SUM(S29DDTRSMTNOITM) AS "DDTRSMTNOITM29", SUM(S29DDERRNOITM) AS "DDERRNOITM29", SUM(S29DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL29",
              SUM(S30DDTRSMTNOITM) AS "DDTRSMTNOITM30", SUM(S30DDERRNOITM) AS "DDERRNOITM30", SUM(S30DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL30",
              SUM(S31DDTRSMTNOITM) AS "DDTRSMTNOITM31", SUM(S31DDERRNOITM) AS "DDERRNOITM31", SUM(S31DDRSPNSAVGVAL) AS "DDRSPNSAVGVAL31"
         FROM $schemaId$.TSEAIST03 A
         LEFT OUTER JOIN $schemaId$.TSEAIHE01 B
		   ON TRIM(A.EAISVCNAME) = B.EAISVCNAME
        WHERE TRIM(A.STATCYM) BETWEEN #searchStart# AND #searchEnd#
        <isNotEmpty prepend="AND" property="searchEaiBzwkDstcd">
		      ( TRIM(A.EAISVCNAME) LIKE CONCAT( '%',CONCAT( UPPER(#searchEaiBzwkDstcd#) , '%') ) OR
		        TRIM(B.EAISVCDESC) LIKE CONCAT( '%',CONCAT( UPPER(#searchEaiBzwkDstcd#) , '%') )  )
		</isNotEmpty>
        GROUP BY A.EAISVCNAME
        	   , B.EAISVCDESC
		ORDER BY A.EAISVCNAME
   </statement>
   
   <statement id="selectDailySituationCount" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
	SELECT COUNT(*) AS "TOTALCOUNT"
       		,  SUM(DDTRSMTNOITM1)    AS "DDTRSMTNOITM1_SUM"
            ,  SUM(DDERRNOITM1)      AS "DDERRNOITM1_SUM"
            ,  SUM(DDTRSMTNOITM2)    AS "DDTRSMTNOITM2_SUM"
            ,  SUM(DDERRNOITM2)      AS "DDERRNOITM2_SUM"
            ,  SUM(DDTRSMTNOITM3)    AS "DDTRSMTNOITM3_SUM"
            ,  SUM(DDERRNOITM3)      AS "DDERRNOITM3_SUM"
            ,  SUM(DDTRSMTNOITM4)    AS "DDTRSMTNOITM4_SUM"
            ,  SUM(DDERRNOITM4)      AS "DDERRNOITM4_SUM"
            ,  SUM(DDTRSMTNOITM5)    AS "DDTRSMTNOITM5_SUM"
            ,  SUM(DDERRNOITM5)      AS "DDERRNOITM5_SUM"
            ,  SUM(DDTRSMTNOITM6)    AS "DDTRSMTNOITM6_SUM"
            ,  SUM(DDERRNOITM6)      AS "DDERRNOITM6_SUM"
            ,  SUM(DDTRSMTNOITM7)    AS "DDTRSMTNOITM7_SUM"
            ,  SUM(DDERRNOITM7)      AS "DDERRNOITM7_SUM"
            ,  SUM(DDTRSMTNOITM8)    AS "DDTRSMTNOITM8_SUM"
            ,  SUM(DDERRNOITM8)      AS "DDERRNOITM8_SUM"
            ,  SUM(DDTRSMTNOITM9)    AS "DDTRSMTNOITM9_SUM"
            ,  SUM(DDERRNOITM9)      AS "DDERRNOITM9_SUM"
            ,  SUM(DDTRSMTNOITM10)   AS "DDTRSMTNOITM10_SUM"
            ,  SUM(DDERRNOITM10)     AS "DDERRNOITM10_SUM"
            ,  SUM(DDTRSMTNOITM11)   AS "DDTRSMTNOITM11_SUM"
            ,  SUM(DDERRNOITM11)     AS "DDERRNOITM11_SUM"
            ,  SUM(DDTRSMTNOITM12)   AS "DDTRSMTNOITM12_SUM"
            ,  SUM(DDERRNOITM12)     AS "DDERRNOITM12_SUM"
            ,  SUM(DDTRSMTNOITM13)   AS "DDTRSMTNOITM13_SUM"
            ,  SUM(DDERRNOITM13)     AS "DDERRNOITM13_SUM"
            ,  SUM(DDTRSMTNOITM14)   AS "DDTRSMTNOITM14_SUM"
            ,  SUM(DDERRNOITM14)     AS "DDERRNOITM14_SUM"
            ,  SUM(DDTRSMTNOITM15)   AS "DDTRSMTNOITM15_SUM"
            ,  SUM(DDERRNOITM15)     AS "DDERRNOITM15_SUM"
            ,  SUM(DDTRSMTNOITM16)   AS "DDTRSMTNOITM16_SUM"
            ,  SUM(DDERRNOITM16)     AS "DDERRNOITM16_SUM"
            ,  SUM(DDTRSMTNOITM17)   AS "DDTRSMTNOITM17_SUM"
            ,  SUM(DDERRNOITM17)     AS "DDERRNOITM17_SUM"
            ,  SUM(DDTRSMTNOITM18)   AS "DDTRSMTNOITM18_SUM"
            ,  SUM(DDERRNOITM18)     AS "DDERRNOITM18_SUM"
            ,  SUM(DDTRSMTNOITM19)   AS "DDTRSMTNOITM19_SUM"
            ,  SUM(DDERRNOITM19)     AS "DDERRNOITM19_SUM"
            ,  SUM(DDTRSMTNOITM20)   AS "DDTRSMTNOITM20_SUM"
            ,  SUM(DDERRNOITM20)     AS "DDERRNOITM20_SUM"
            ,  SUM(DDTRSMTNOITM21)   AS "DDTRSMTNOITM21_SUM"
            ,  SUM(DDERRNOITM21)     AS "DDERRNOITM21_SUM"
            ,  SUM(DDTRSMTNOITM22)   AS "DDTRSMTNOITM22_SUM"
            ,  SUM(DDERRNOITM22)     AS "DDERRNOITM22_SUM"
            ,  SUM(DDTRSMTNOITM23)   AS "DDTRSMTNOITM23_SUM"
            ,  SUM(DDERRNOITM23)     AS "DDERRNOITM23_SUM"
            ,  SUM(DDTRSMTNOITM24)   AS "DDTRSMTNOITM24_SUM"
            ,  SUM(DDERRNOITM24)     AS "DDERRNOITM24_SUM"
            ,  SUM(DDTRSMTNOITM25)   AS "DDTRSMTNOITM25_SUM"
            ,  SUM(DDERRNOITM25)     AS "DDERRNOITM25_SUM"
            ,  SUM(DDTRSMTNOITM26)   AS "DDTRSMTNOITM26_SUM"
            ,  SUM(DDERRNOITM26)     AS "DDERRNOITM26_SUM"
            ,  SUM(DDTRSMTNOITM27)   AS "DDTRSMTNOITM27_SUM"
            ,  SUM(DDERRNOITM27)     AS "DDERRNOITM27_SUM"
            ,  SUM(DDTRSMTNOITM28)   AS "DDTRSMTNOITM28_SUM"
            ,  SUM(DDERRNOITM28)     AS "DDERRNOITM28_SUM"
            ,  SUM(DDTRSMTNOITM29)   AS "DDTRSMTNOITM29_SUM"
            ,  SUM(DDERRNOITM29)     AS "DDERRNOITM29_SUM"
            ,  SUM(DDTRSMTNOITM30)   AS "DDTRSMTNOITM30_SUM"
            ,  SUM(DDERRNOITM30)     AS "DDERRNOITM30_SUM"
            ,  SUM(DDTRSMTNOITM31)   AS "DDTRSMTNOITM31_SUM"
            ,  SUM(DDERRNOITM31)     AS "DDERRNOITM31_SUM"

FROM(
			SELECT            
            EAIBZWKDSTCD,
            EAISVCNAME AS "EAISVCDESC",          
              SUM(S1DDTRSMTNOITM)  AS DDTRSMTNOITM1,  SUM(S1DDERRNOITM)  AS DDERRNOITM1,  ROUND(AVG(S1DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL1,
              SUM(S2DDTRSMTNOITM)  AS DDTRSMTNOITM2,  SUM(S2DDERRNOITM)  AS DDERRNOITM2,  ROUND(AVG(S2DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL2,
              SUM(S3DDTRSMTNOITM)  AS DDTRSMTNOITM3,  SUM(S3DDERRNOITM)  AS DDERRNOITM3,  ROUND(AVG(S3DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL3,
              SUM(S4DDTRSMTNOITM)  AS DDTRSMTNOITM4,  SUM(S4DDERRNOITM)  AS DDERRNOITM4,  ROUND(AVG(S4DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL4,
              SUM(S5DDTRSMTNOITM)  AS DDTRSMTNOITM5,  SUM(S5DDERRNOITM)  AS DDERRNOITM5,  ROUND(AVG(S5DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL5,
              SUM(S6DDTRSMTNOITM)  AS DDTRSMTNOITM6,  SUM(S6DDERRNOITM)  AS DDERRNOITM6,  ROUND(AVG(S6DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL6,
              SUM(S7DDTRSMTNOITM)  AS DDTRSMTNOITM7,  SUM(S7DDERRNOITM)  AS DDERRNOITM7,  ROUND(AVG(S7DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL7,
              SUM(S8DDTRSMTNOITM)  AS DDTRSMTNOITM8,  SUM(S8DDERRNOITM)  AS DDERRNOITM8,  ROUND(AVG(S8DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL8,
              SUM(S9DDTRSMTNOITM)  AS DDTRSMTNOITM9,  SUM(S9DDERRNOITM)  AS DDERRNOITM9,  ROUND(AVG(S9DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL9,
              SUM(S10DDTRSMTNOITM) AS DDTRSMTNOITM10, SUM(S10DDERRNOITM) AS DDERRNOITM10, ROUND(AVG(S10DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL10,
              SUM(S11DDTRSMTNOITM) AS DDTRSMTNOITM11, SUM(S11DDERRNOITM) AS DDERRNOITM11, ROUND(AVG(S11DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL11,
              SUM(S12DDTRSMTNOITM) AS DDTRSMTNOITM12, SUM(S12DDERRNOITM) AS DDERRNOITM12, ROUND(AVG(S12DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL12,
              SUM(S13DDTRSMTNOITM) AS DDTRSMTNOITM13, SUM(S13DDERRNOITM) AS DDERRNOITM13, ROUND(AVG(S13DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL13,
              SUM(S14DDTRSMTNOITM) AS DDTRSMTNOITM14, SUM(S14DDERRNOITM) AS DDERRNOITM14, ROUND(AVG(S14DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL14,
              SUM(S15DDTRSMTNOITM) AS DDTRSMTNOITM15, SUM(S15DDERRNOITM) AS DDERRNOITM15, ROUND(AVG(S15DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL15,
              SUM(S16DDTRSMTNOITM) AS DDTRSMTNOITM16, SUM(S16DDERRNOITM) AS DDERRNOITM16, ROUND(AVG(S16DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL16,
              SUM(S17DDTRSMTNOITM) AS DDTRSMTNOITM17, SUM(S17DDERRNOITM) AS DDERRNOITM17, ROUND(AVG(S17DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL17,
              SUM(S18DDTRSMTNOITM) AS DDTRSMTNOITM18, SUM(S18DDERRNOITM) AS DDERRNOITM18, ROUND(AVG(S18DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL18,
              SUM(S19DDTRSMTNOITM) AS DDTRSMTNOITM19, SUM(S19DDERRNOITM) AS DDERRNOITM19, ROUND(AVG(S19DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL19,
              SUM(S20DDTRSMTNOITM) AS DDTRSMTNOITM20, SUM(S20DDERRNOITM) AS DDERRNOITM20, ROUND(AVG(S20DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL20,
              SUM(S21DDTRSMTNOITM) AS DDTRSMTNOITM21, SUM(S21DDERRNOITM) AS DDERRNOITM21, ROUND(AVG(S21DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL21,
              SUM(S22DDTRSMTNOITM) AS DDTRSMTNOITM22, SUM(S22DDERRNOITM) AS DDERRNOITM22, ROUND(AVG(S22DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL22,
              SUM(S23DDTRSMTNOITM) AS DDTRSMTNOITM23, SUM(S23DDERRNOITM) AS DDERRNOITM23, ROUND(AVG(S23DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL23,
              SUM(S24DDTRSMTNOITM) AS DDTRSMTNOITM24, SUM(S24DDERRNOITM) AS DDERRNOITM24, ROUND(AVG(S24DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL24,
              SUM(S25DDTRSMTNOITM) AS DDTRSMTNOITM25, SUM(S25DDERRNOITM) AS DDERRNOITM25, ROUND(AVG(S25DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL25,
              SUM(S26DDTRSMTNOITM) AS DDTRSMTNOITM26, SUM(S26DDERRNOITM) AS DDERRNOITM26, ROUND(AVG(S26DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL26,
              SUM(S27DDTRSMTNOITM) AS DDTRSMTNOITM27, SUM(S27DDERRNOITM) AS DDERRNOITM27, ROUND(AVG(S27DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL27,
              SUM(S28DDTRSMTNOITM) AS DDTRSMTNOITM28, SUM(S28DDERRNOITM) AS DDERRNOITM28, ROUND(AVG(S28DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL28,
              SUM(S29DDTRSMTNOITM) AS DDTRSMTNOITM29, SUM(S29DDERRNOITM) AS DDERRNOITM29, ROUND(AVG(S29DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL29,
              SUM(S30DDTRSMTNOITM) AS DDTRSMTNOITM30, SUM(S30DDERRNOITM) AS DDERRNOITM30, ROUND(AVG(S30DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL30,
              SUM(S31DDTRSMTNOITM) AS DDTRSMTNOITM31, SUM(S31DDERRNOITM) AS DDERRNOITM31, ROUND(AVG(S31DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL31
        FROM (
              SELECT
              STATCYM,
              EAIBZWKDSTCD,
              EAISVCNAME,           
              COALESCE(CASE WHEN DD = '01' THEN PROCCOUNT END, 0) AS S1DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '02' THEN PROCCOUNT END, 0) AS S2DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '03' THEN PROCCOUNT END, 0) AS S3DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '04' THEN PROCCOUNT END, 0) AS S4DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '05' THEN PROCCOUNT END, 0) AS S5DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '06' THEN PROCCOUNT END, 0) AS S6DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '07' THEN PROCCOUNT END, 0) AS S7DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '08' THEN PROCCOUNT END, 0) AS S8DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '09' THEN PROCCOUNT END, 0) AS S9DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '10' THEN PROCCOUNT END, 0) AS S10DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '11' THEN PROCCOUNT END, 0) AS S11DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '12' THEN PROCCOUNT END, 0) AS S12DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '13' THEN PROCCOUNT END, 0) AS S13DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '14' THEN PROCCOUNT END, 0) AS S14DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '15' THEN PROCCOUNT END, 0) AS S15DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '16' THEN PROCCOUNT END, 0) AS S16DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '17' THEN PROCCOUNT END, 0) AS S17DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '18' THEN PROCCOUNT END, 0) AS S18DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '19' THEN PROCCOUNT END, 0) AS S19DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '20' THEN PROCCOUNT END, 0) AS S20DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '21' THEN PROCCOUNT END, 0) AS S21DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '22' THEN PROCCOUNT END, 0) AS S22DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '23' THEN PROCCOUNT END, 0) AS S23DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '24' THEN PROCCOUNT END, 0) AS S24DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '25' THEN PROCCOUNT END, 0) AS S25DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '26' THEN PROCCOUNT END, 0) AS S26DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '27' THEN PROCCOUNT END, 0) AS S27DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '28' THEN PROCCOUNT END, 0) AS S28DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '29' THEN PROCCOUNT END, 0) AS S29DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '30' THEN PROCCOUNT END, 0) AS S30DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '31' THEN PROCCOUNT END, 0) AS S31DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '01' THEN ERRCOUNT END, 0) AS S1DDERRNOITM,
              COALESCE(CASE WHEN DD = '02' THEN ERRCOUNT END, 0) AS S2DDERRNOITM,
              COALESCE(CASE WHEN DD = '03' THEN ERRCOUNT END, 0) AS S3DDERRNOITM,
              COALESCE(CASE WHEN DD = '04' THEN ERRCOUNT END, 0) AS S4DDERRNOITM,
              COALESCE(CASE WHEN DD = '05' THEN ERRCOUNT END, 0) AS S5DDERRNOITM,
              COALESCE(CASE WHEN DD = '06' THEN ERRCOUNT END, 0) AS S6DDERRNOITM,
              COALESCE(CASE WHEN DD = '07' THEN ERRCOUNT END, 0) AS S7DDERRNOITM,
              COALESCE(CASE WHEN DD = '08' THEN ERRCOUNT END, 0) AS S8DDERRNOITM,
              COALESCE(CASE WHEN DD = '09' THEN ERRCOUNT END, 0) AS S9DDERRNOITM,
              COALESCE(CASE WHEN DD = '10' THEN ERRCOUNT END, 0) AS S10DDERRNOITM,
              COALESCE(CASE WHEN DD = '11' THEN ERRCOUNT END, 0) AS S11DDERRNOITM,
              COALESCE(CASE WHEN DD = '12' THEN ERRCOUNT END, 0) AS S12DDERRNOITM,
              COALESCE(CASE WHEN DD = '13' THEN ERRCOUNT END, 0) AS S13DDERRNOITM,
              COALESCE(CASE WHEN DD = '14' THEN ERRCOUNT END, 0) AS S14DDERRNOITM,
              COALESCE(CASE WHEN DD = '15' THEN ERRCOUNT END, 0) AS S15DDERRNOITM,
              COALESCE(CASE WHEN DD = '16' THEN ERRCOUNT END, 0) AS S16DDERRNOITM,
              COALESCE(CASE WHEN DD = '17' THEN ERRCOUNT END, 0) AS S17DDERRNOITM,
              COALESCE(CASE WHEN DD = '18' THEN ERRCOUNT END, 0) AS S18DDERRNOITM,
              COALESCE(CASE WHEN DD = '19' THEN ERRCOUNT END, 0) AS S19DDERRNOITM,
              COALESCE(CASE WHEN DD = '20' THEN ERRCOUNT END, 0) AS S20DDERRNOITM,
              COALESCE(CASE WHEN DD = '21' THEN ERRCOUNT END, 0) AS S21DDERRNOITM,
              COALESCE(CASE WHEN DD = '22' THEN ERRCOUNT END, 0) AS S22DDERRNOITM,
              COALESCE(CASE WHEN DD = '23' THEN ERRCOUNT END, 0) AS S23DDERRNOITM,
              COALESCE(CASE WHEN DD = '24' THEN ERRCOUNT END, 0) AS S24DDERRNOITM,
              COALESCE(CASE WHEN DD = '25' THEN ERRCOUNT END, 0) AS S25DDERRNOITM,
              COALESCE(CASE WHEN DD = '26' THEN ERRCOUNT END, 0) AS S26DDERRNOITM,
              COALESCE(CASE WHEN DD = '27' THEN ERRCOUNT END, 0) AS S27DDERRNOITM,
              COALESCE(CASE WHEN DD = '28' THEN ERRCOUNT END, 0) AS S28DDERRNOITM,
              COALESCE(CASE WHEN DD = '29' THEN ERRCOUNT END, 0) AS S29DDERRNOITM,
              COALESCE(CASE WHEN DD = '30' THEN ERRCOUNT END, 0) AS S30DDERRNOITM,
              COALESCE(CASE WHEN DD = '31' THEN ERRCOUNT END, 0) AS S31DDERRNOITM,
              COALESCE(CASE WHEN DD = '01' THEN RSPNSAVG END, 0) AS S1DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '02' THEN RSPNSAVG END, 0) AS S2DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '03' THEN RSPNSAVG END, 0) AS S3DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '04' THEN RSPNSAVG END, 0) AS S4DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '05' THEN RSPNSAVG END, 0) AS S5DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '06' THEN RSPNSAVG END, 0) AS S6DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '07' THEN RSPNSAVG END, 0) AS S7DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '08' THEN RSPNSAVG END, 0) AS S8DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '09' THEN RSPNSAVG END, 0) AS S9DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '10' THEN RSPNSAVG END, 0) AS S10DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '11' THEN RSPNSAVG END, 0) AS S11DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '12' THEN RSPNSAVG END, 0) AS S12DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '13' THEN RSPNSAVG END, 0) AS S13DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '14' THEN RSPNSAVG END, 0) AS S14DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '15' THEN RSPNSAVG END, 0) AS S15DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '16' THEN RSPNSAVG END, 0) AS S16DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '17' THEN RSPNSAVG END, 0) AS S17DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '18' THEN RSPNSAVG END, 0) AS S18DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '19' THEN RSPNSAVG END, 0) AS S19DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '20' THEN RSPNSAVG END, 0) AS S20DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '21' THEN RSPNSAVG END, 0) AS S21DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '22' THEN RSPNSAVG END, 0) AS S22DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '23' THEN RSPNSAVG END, 0) AS S23DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '24' THEN RSPNSAVG END, 0) AS S24DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '25' THEN RSPNSAVG END, 0) AS S25DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '26' THEN RSPNSAVG END, 0) AS S26DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '27' THEN RSPNSAVG END, 0) AS S27DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '28' THEN RSPNSAVG END, 0) AS S28DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '29' THEN RSPNSAVG END, 0) AS S29DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '30' THEN RSPNSAVG END, 0) AS S30DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '31' THEN RSPNSAVG END, 0) AS S31DDRSPNSAVGVAL
        FROM
            (
                  SELECT
                    SUBSTR(STATCYMD, 1, 6) AS STATCYM,
                    SUBSTR(STATCYMD, 7, 2) AS DD,
                    EAIBZWKDSTCD,
                    EAISVCNAME,                
                      (
                      S0HHTRSMTNOITM +
                      S1HHTRSMTNOITM +
                      S2HHTRSMTNOITM +
                      S3HHTRSMTNOITM +
                      S4HHTRSMTNOITM +
                      S5HHTRSMTNOITM +
                      S6HHTRSMTNOITM +
                      S7HHTRSMTNOITM +
                      S8HHTRSMTNOITM +
                      S9HHTRSMTNOITM +
                      S10HHTRSMTNOITM +
                      S11HHTRSMTNOITM +
                      S12HHTRSMTNOITM +
                      S13HHTRSMTNOITM +
                      S14HHTRSMTNOITM +
                      S15HHTRSMTNOITM +
                      S16HHTRSMTNOITM +
                      S17HHTRSMTNOITM +
                      S18HHTRSMTNOITM +
                      S19HHTRSMTNOITM +
                      S20HHTRSMTNOITM +
                      S21HHTRSMTNOITM +
                      S22HHTRSMTNOITM +
                      S23HHTRSMTNOITM
                      ) AS PROCCOUNT,
                      (
                S0HHERRNOITM +
                S1HHERRNOITM +
                S2HHERRNOITM +
                S3HHERRNOITM +
                S4HHERRNOITM +
                S5HHERRNOITM +
                S6HHERRNOITM +
                S7HHERRNOITM +
                S8HHERRNOITM +
                S9HHERRNOITM +
                S10HHERRNOITM +
                S11HHERRNOITM +
                S12HHERRNOITM +
                S13HHERRNOITM +
                S14HHERRNOITM +
                S15HHERRNOITM +
                S16HHERRNOITM +
                S17HHERRNOITM +
                S18HHERRNOITM +
                S19HHERRNOITM +
                S20HHERRNOITM +
                S21HHERRNOITM +
                S22HHERRNOITM +
                S23HHERRNOITM
              ) AS ERRCOUNT,
              ROUND((
                S0HHRSPNSAVGVAL +
                S1HHRSPNSAVGVAL +
                S2HHRSPNSAVGVAL +
                S3HHRSPNSAVGVAL +
                S4HHRSPNSAVGVAL +
                S5HHRSPNSAVGVAL +
                S6HHRSPNSAVGVAL +
                S7HHRSPNSAVGVAL +
                S8HHRSPNSAVGVAL +
                S9HHRSPNSAVGVAL +
                S10HHRSPNSAVGVAL +
                S11HHRSPNSAVGVAL +
                S12HHRSPNSAVGVAL +
                S13HHRSPNSAVGVAL +
                S14HHRSPNSAVGVAL +
                S15HHRSPNSAVGVAL +
                S16HHRSPNSAVGVAL +
                S17HHRSPNSAVGVAL +
                S18HHRSPNSAVGVAL +
                S19HHRSPNSAVGVAL +
                S20HHRSPNSAVGVAL +
                S21HHRSPNSAVGVAL +
                S22HHRSPNSAVGVAL +
                S23HHRSPNSAVGVAL
              )/24, 3) AS RSPNSAVG
                  FROM  $schemaId$.TSEAIST02
                  WHERE STATCYMD BETWEEN  #searchStart# AND #searchEnd#                   
              ) A
              ) B
                  GROUP BY
                          STATCYM,
                          EAIBZWKDSTCD,
                          EAISVCNAME
	) T
   </statement>
   
   <statement id="selectByEaiSvcNameDailySituation" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
           SELECT     
              B.EAISVCNAME,
              COALESCE(C.EAISVCDESC, 'UNKNOWN') AS "EAISVCDESC",          
              SUM(S1DDTRSMTNOITM)  AS DDTRSMTNOITM1,  SUM(S1DDERRNOITM)  AS DDERRNOITM1,  ROUND(AVG(S1DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL1,
              SUM(S2DDTRSMTNOITM)  AS DDTRSMTNOITM2,  SUM(S2DDERRNOITM)  AS DDERRNOITM2,  ROUND(AVG(S2DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL2,
              SUM(S3DDTRSMTNOITM)  AS DDTRSMTNOITM3,  SUM(S3DDERRNOITM)  AS DDERRNOITM3,  ROUND(AVG(S3DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL3,
              SUM(S4DDTRSMTNOITM)  AS DDTRSMTNOITM4,  SUM(S4DDERRNOITM)  AS DDERRNOITM4,  ROUND(AVG(S4DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL4,
              SUM(S5DDTRSMTNOITM)  AS DDTRSMTNOITM5,  SUM(S5DDERRNOITM)  AS DDERRNOITM5,  ROUND(AVG(S5DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL5,
              SUM(S6DDTRSMTNOITM)  AS DDTRSMTNOITM6,  SUM(S6DDERRNOITM)  AS DDERRNOITM6,  ROUND(AVG(S6DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL6,
              SUM(S7DDTRSMTNOITM)  AS DDTRSMTNOITM7,  SUM(S7DDERRNOITM)  AS DDERRNOITM7,  ROUND(AVG(S7DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL7,
              SUM(S8DDTRSMTNOITM)  AS DDTRSMTNOITM8,  SUM(S8DDERRNOITM)  AS DDERRNOITM8,  ROUND(AVG(S8DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL8,
              SUM(S9DDTRSMTNOITM)  AS DDTRSMTNOITM9,  SUM(S9DDERRNOITM)  AS DDERRNOITM9,  ROUND(AVG(S9DDRSPNSAVGVAL), 3)  AS DDRSPNSAVGVAL9,
              SUM(S10DDTRSMTNOITM) AS DDTRSMTNOITM10, SUM(S10DDERRNOITM) AS DDERRNOITM10, ROUND(AVG(S10DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL10,
              SUM(S11DDTRSMTNOITM) AS DDTRSMTNOITM11, SUM(S11DDERRNOITM) AS DDERRNOITM11, ROUND(AVG(S11DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL11,
              SUM(S12DDTRSMTNOITM) AS DDTRSMTNOITM12, SUM(S12DDERRNOITM) AS DDERRNOITM12, ROUND(AVG(S12DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL12,
              SUM(S13DDTRSMTNOITM) AS DDTRSMTNOITM13, SUM(S13DDERRNOITM) AS DDERRNOITM13, ROUND(AVG(S13DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL13,
              SUM(S14DDTRSMTNOITM) AS DDTRSMTNOITM14, SUM(S14DDERRNOITM) AS DDERRNOITM14, ROUND(AVG(S14DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL14,
              SUM(S15DDTRSMTNOITM) AS DDTRSMTNOITM15, SUM(S15DDERRNOITM) AS DDERRNOITM15, ROUND(AVG(S15DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL15,
              SUM(S16DDTRSMTNOITM) AS DDTRSMTNOITM16, SUM(S16DDERRNOITM) AS DDERRNOITM16, ROUND(AVG(S16DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL16,
              SUM(S17DDTRSMTNOITM) AS DDTRSMTNOITM17, SUM(S17DDERRNOITM) AS DDERRNOITM17, ROUND(AVG(S17DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL17,
              SUM(S18DDTRSMTNOITM) AS DDTRSMTNOITM18, SUM(S18DDERRNOITM) AS DDERRNOITM18, ROUND(AVG(S18DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL18,
              SUM(S19DDTRSMTNOITM) AS DDTRSMTNOITM19, SUM(S19DDERRNOITM) AS DDERRNOITM19, ROUND(AVG(S19DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL19,
              SUM(S20DDTRSMTNOITM) AS DDTRSMTNOITM20, SUM(S20DDERRNOITM) AS DDERRNOITM20, ROUND(AVG(S20DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL20,
              SUM(S21DDTRSMTNOITM) AS DDTRSMTNOITM21, SUM(S21DDERRNOITM) AS DDERRNOITM21, ROUND(AVG(S21DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL21,
              SUM(S22DDTRSMTNOITM) AS DDTRSMTNOITM22, SUM(S22DDERRNOITM) AS DDERRNOITM22, ROUND(AVG(S22DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL22,
              SUM(S23DDTRSMTNOITM) AS DDTRSMTNOITM23, SUM(S23DDERRNOITM) AS DDERRNOITM23, ROUND(AVG(S23DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL23,
              SUM(S24DDTRSMTNOITM) AS DDTRSMTNOITM24, SUM(S24DDERRNOITM) AS DDERRNOITM24, ROUND(AVG(S24DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL24,
              SUM(S25DDTRSMTNOITM) AS DDTRSMTNOITM25, SUM(S25DDERRNOITM) AS DDERRNOITM25, ROUND(AVG(S25DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL25,
              SUM(S26DDTRSMTNOITM) AS DDTRSMTNOITM26, SUM(S26DDERRNOITM) AS DDERRNOITM26, ROUND(AVG(S26DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL26,
              SUM(S27DDTRSMTNOITM) AS DDTRSMTNOITM27, SUM(S27DDERRNOITM) AS DDERRNOITM27, ROUND(AVG(S27DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL27,
              SUM(S28DDTRSMTNOITM) AS DDTRSMTNOITM28, SUM(S28DDERRNOITM) AS DDERRNOITM28, ROUND(AVG(S28DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL28,
              SUM(S29DDTRSMTNOITM) AS DDTRSMTNOITM29, SUM(S29DDERRNOITM) AS DDERRNOITM29, ROUND(AVG(S29DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL29,
              SUM(S30DDTRSMTNOITM) AS DDTRSMTNOITM30, SUM(S30DDERRNOITM) AS DDERRNOITM30, ROUND(AVG(S30DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL30,
              SUM(S31DDTRSMTNOITM) AS DDTRSMTNOITM31, SUM(S31DDERRNOITM) AS DDERRNOITM31, ROUND(AVG(S31DDRSPNSAVGVAL), 3) AS DDRSPNSAVGVAL31
        FROM (
              SELECT
              STATCYM,
              EAIBZWKDSTCD,
              EAISVCNAME,           
              COALESCE(CASE WHEN DD = '01' THEN PROCCOUNT END, 0) AS S1DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '02' THEN PROCCOUNT END, 0) AS S2DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '03' THEN PROCCOUNT END, 0) AS S3DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '04' THEN PROCCOUNT END, 0) AS S4DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '05' THEN PROCCOUNT END, 0) AS S5DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '06' THEN PROCCOUNT END, 0) AS S6DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '07' THEN PROCCOUNT END, 0) AS S7DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '08' THEN PROCCOUNT END, 0) AS S8DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '09' THEN PROCCOUNT END, 0) AS S9DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '10' THEN PROCCOUNT END, 0) AS S10DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '11' THEN PROCCOUNT END, 0) AS S11DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '12' THEN PROCCOUNT END, 0) AS S12DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '13' THEN PROCCOUNT END, 0) AS S13DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '14' THEN PROCCOUNT END, 0) AS S14DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '15' THEN PROCCOUNT END, 0) AS S15DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '16' THEN PROCCOUNT END, 0) AS S16DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '17' THEN PROCCOUNT END, 0) AS S17DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '18' THEN PROCCOUNT END, 0) AS S18DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '19' THEN PROCCOUNT END, 0) AS S19DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '20' THEN PROCCOUNT END, 0) AS S20DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '21' THEN PROCCOUNT END, 0) AS S21DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '22' THEN PROCCOUNT END, 0) AS S22DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '23' THEN PROCCOUNT END, 0) AS S23DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '24' THEN PROCCOUNT END, 0) AS S24DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '25' THEN PROCCOUNT END, 0) AS S25DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '26' THEN PROCCOUNT END, 0) AS S26DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '27' THEN PROCCOUNT END, 0) AS S27DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '28' THEN PROCCOUNT END, 0) AS S28DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '29' THEN PROCCOUNT END, 0) AS S29DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '30' THEN PROCCOUNT END, 0) AS S30DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '31' THEN PROCCOUNT END, 0) AS S31DDTRSMTNOITM,
              COALESCE(CASE WHEN DD = '01' THEN ERRCOUNT END, 0) AS S1DDERRNOITM,
              COALESCE(CASE WHEN DD = '02' THEN ERRCOUNT END, 0) AS S2DDERRNOITM,
              COALESCE(CASE WHEN DD = '03' THEN ERRCOUNT END, 0) AS S3DDERRNOITM,
              COALESCE(CASE WHEN DD = '04' THEN ERRCOUNT END, 0) AS S4DDERRNOITM,
              COALESCE(CASE WHEN DD = '05' THEN ERRCOUNT END, 0) AS S5DDERRNOITM,
              COALESCE(CASE WHEN DD = '06' THEN ERRCOUNT END, 0) AS S6DDERRNOITM,
              COALESCE(CASE WHEN DD = '07' THEN ERRCOUNT END, 0) AS S7DDERRNOITM,
              COALESCE(CASE WHEN DD = '08' THEN ERRCOUNT END, 0) AS S8DDERRNOITM,
              COALESCE(CASE WHEN DD = '09' THEN ERRCOUNT END, 0) AS S9DDERRNOITM,
              COALESCE(CASE WHEN DD = '10' THEN ERRCOUNT END, 0) AS S10DDERRNOITM,
              COALESCE(CASE WHEN DD = '11' THEN ERRCOUNT END, 0) AS S11DDERRNOITM,
              COALESCE(CASE WHEN DD = '12' THEN ERRCOUNT END, 0) AS S12DDERRNOITM,
              COALESCE(CASE WHEN DD = '13' THEN ERRCOUNT END, 0) AS S13DDERRNOITM,
              COALESCE(CASE WHEN DD = '14' THEN ERRCOUNT END, 0) AS S14DDERRNOITM,
              COALESCE(CASE WHEN DD = '15' THEN ERRCOUNT END, 0) AS S15DDERRNOITM,
              COALESCE(CASE WHEN DD = '16' THEN ERRCOUNT END, 0) AS S16DDERRNOITM,
              COALESCE(CASE WHEN DD = '17' THEN ERRCOUNT END, 0) AS S17DDERRNOITM,
              COALESCE(CASE WHEN DD = '18' THEN ERRCOUNT END, 0) AS S18DDERRNOITM,
              COALESCE(CASE WHEN DD = '19' THEN ERRCOUNT END, 0) AS S19DDERRNOITM,
              COALESCE(CASE WHEN DD = '20' THEN ERRCOUNT END, 0) AS S20DDERRNOITM,
              COALESCE(CASE WHEN DD = '21' THEN ERRCOUNT END, 0) AS S21DDERRNOITM,
              COALESCE(CASE WHEN DD = '22' THEN ERRCOUNT END, 0) AS S22DDERRNOITM,
              COALESCE(CASE WHEN DD = '23' THEN ERRCOUNT END, 0) AS S23DDERRNOITM,
              COALESCE(CASE WHEN DD = '24' THEN ERRCOUNT END, 0) AS S24DDERRNOITM,
              COALESCE(CASE WHEN DD = '25' THEN ERRCOUNT END, 0) AS S25DDERRNOITM,
              COALESCE(CASE WHEN DD = '26' THEN ERRCOUNT END, 0) AS S26DDERRNOITM,
              COALESCE(CASE WHEN DD = '27' THEN ERRCOUNT END, 0) AS S27DDERRNOITM,
              COALESCE(CASE WHEN DD = '28' THEN ERRCOUNT END, 0) AS S28DDERRNOITM,
              COALESCE(CASE WHEN DD = '29' THEN ERRCOUNT END, 0) AS S29DDERRNOITM,
              COALESCE(CASE WHEN DD = '30' THEN ERRCOUNT END, 0) AS S30DDERRNOITM,
              COALESCE(CASE WHEN DD = '31' THEN ERRCOUNT END, 0) AS S31DDERRNOITM,
              COALESCE(CASE WHEN DD = '01' THEN RSPNSAVG END, 0) AS S1DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '02' THEN RSPNSAVG END, 0) AS S2DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '03' THEN RSPNSAVG END, 0) AS S3DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '04' THEN RSPNSAVG END, 0) AS S4DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '05' THEN RSPNSAVG END, 0) AS S5DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '06' THEN RSPNSAVG END, 0) AS S6DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '07' THEN RSPNSAVG END, 0) AS S7DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '08' THEN RSPNSAVG END, 0) AS S8DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '09' THEN RSPNSAVG END, 0) AS S9DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '10' THEN RSPNSAVG END, 0) AS S10DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '11' THEN RSPNSAVG END, 0) AS S11DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '12' THEN RSPNSAVG END, 0) AS S12DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '13' THEN RSPNSAVG END, 0) AS S13DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '14' THEN RSPNSAVG END, 0) AS S14DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '15' THEN RSPNSAVG END, 0) AS S15DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '16' THEN RSPNSAVG END, 0) AS S16DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '17' THEN RSPNSAVG END, 0) AS S17DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '18' THEN RSPNSAVG END, 0) AS S18DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '19' THEN RSPNSAVG END, 0) AS S19DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '20' THEN RSPNSAVG END, 0) AS S20DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '21' THEN RSPNSAVG END, 0) AS S21DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '22' THEN RSPNSAVG END, 0) AS S22DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '23' THEN RSPNSAVG END, 0) AS S23DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '24' THEN RSPNSAVG END, 0) AS S24DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '25' THEN RSPNSAVG END, 0) AS S25DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '26' THEN RSPNSAVG END, 0) AS S26DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '27' THEN RSPNSAVG END, 0) AS S27DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '28' THEN RSPNSAVG END, 0) AS S28DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '29' THEN RSPNSAVG END, 0) AS S29DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '30' THEN RSPNSAVG END, 0) AS S30DDRSPNSAVGVAL,
              COALESCE(CASE WHEN DD = '31' THEN RSPNSAVG END, 0) AS S31DDRSPNSAVGVAL
        FROM
            (
                  SELECT
                    SUBSTR(STATCYMD, 1, 6) AS STATCYM,
                    SUBSTR(STATCYMD, 7, 2) AS DD,
                    EAIBZWKDSTCD,
                    EAISVCNAME,                
                      (
                      S0HHTRSMTNOITM +
                      S1HHTRSMTNOITM +
                      S2HHTRSMTNOITM +
                      S3HHTRSMTNOITM +
                      S4HHTRSMTNOITM +
                      S5HHTRSMTNOITM +
                      S6HHTRSMTNOITM +
                      S7HHTRSMTNOITM +
                      S8HHTRSMTNOITM +
                      S9HHTRSMTNOITM +
                      S10HHTRSMTNOITM +
                      S11HHTRSMTNOITM +
                      S12HHTRSMTNOITM +
                      S13HHTRSMTNOITM +
                      S14HHTRSMTNOITM +
                      S15HHTRSMTNOITM +
                      S16HHTRSMTNOITM +
                      S17HHTRSMTNOITM +
                      S18HHTRSMTNOITM +
                      S19HHTRSMTNOITM +
                      S20HHTRSMTNOITM +
                      S21HHTRSMTNOITM +
                      S22HHTRSMTNOITM +
                      S23HHTRSMTNOITM
                      ) AS PROCCOUNT,
                      (
                S0HHERRNOITM +
                S1HHERRNOITM +
                S2HHERRNOITM +
                S3HHERRNOITM +
                S4HHERRNOITM +
                S5HHERRNOITM +
                S6HHERRNOITM +
                S7HHERRNOITM +
                S8HHERRNOITM +
                S9HHERRNOITM +
                S10HHERRNOITM +
                S11HHERRNOITM +
                S12HHERRNOITM +
                S13HHERRNOITM +
                S14HHERRNOITM +
                S15HHERRNOITM +
                S16HHERRNOITM +
                S17HHERRNOITM +
                S18HHERRNOITM +
                S19HHERRNOITM +
                S20HHERRNOITM +
                S21HHERRNOITM +
                S22HHERRNOITM +
                S23HHERRNOITM
              ) AS ERRCOUNT,
              ROUND((
                S0HHRSPNSAVGVAL +
                S1HHRSPNSAVGVAL +
                S2HHRSPNSAVGVAL +
                S3HHRSPNSAVGVAL +
                S4HHRSPNSAVGVAL +
                S5HHRSPNSAVGVAL +
                S6HHRSPNSAVGVAL +
                S7HHRSPNSAVGVAL +
                S8HHRSPNSAVGVAL +
                S9HHRSPNSAVGVAL +
                S10HHRSPNSAVGVAL +
                S11HHRSPNSAVGVAL +
                S12HHRSPNSAVGVAL +
                S13HHRSPNSAVGVAL +
                S14HHRSPNSAVGVAL +
                S15HHRSPNSAVGVAL +
                S16HHRSPNSAVGVAL +
                S17HHRSPNSAVGVAL +
                S18HHRSPNSAVGVAL +
                S19HHRSPNSAVGVAL +
                S20HHRSPNSAVGVAL +
                S21HHRSPNSAVGVAL +
                S22HHRSPNSAVGVAL +
                S23HHRSPNSAVGVAL
              )/24, 3) AS RSPNSAVG
                  FROM  $schemaId$.TSEAIST02
                  WHERE STATCYMD BETWEEN  #searchStart# AND #searchEnd#                    
           ) A
    ) B
    LEFT OUTER JOIN $schemaId$.TSEAIHE01 C
	   ON TRIM(B.EAISVCNAME) = C.EAISVCNAME
	<dynamic prepend="WHERE">
		<isNotEmpty prepend="AND" property="searchEaiBzwkDstcd">
			( TRIM(B.EAISVCNAME) LIKE CONCAT( '%',CONCAT( UPPER(#searchEaiBzwkDstcd#) , '%') ) OR
			  TRIM(C.EAISVCDESC) LIKE CONCAT( '%',CONCAT( UPPER(#searchEaiBzwkDstcd#) , '%') ) )
		</isNotEmpty>
	</dynamic>	      
    GROUP BY
      B.STATCYM,
      B.EAIBZWKDSTCD,
      B.EAISVCNAME,
      C.EAISVCDESC    
   </statement>
   
</sqlMap>
