<jsp:directive.page pageEncoding="UTF-8" />
<!-- 帳票統計情報検索 -->
<og:equals val1="{@ACTION}" val2="SHUKEI" >
	<og:value key="SQL" >
		select SYSTEM_ID,{@CLM_LISTID} {@CLM_JOKEN} {@CLM_DMN_NAME} {@CLM_DYSET}
				round(sum(TMDIFF),1) as SUM,count(*) as CNT, 
				round(sum(TMDIFF)/count(*),1) as AVRG, sum(SUDATA) as SUDATA
		from (
			select a.SYSTEM_ID,a.LISTID,b.LISTNAME,a.JOKEN,a.DMN_NAME,a.DYSET,a.DYUPD,
					decode(a.PGUPD,'REP01','1','0') as DTUPD,
					DECODE(a.SUDATA,0,1,a.SUDATA) as SUDATA,
					(to_date( a.DYUPD,'YYYYMMDDHH24MISS' ) - to_date( a.DYSET,'YYYYMMDDHH24MISS' )) * 86400 as TMDIFF
			from    GE50 a left outer join GE54 b
			on		a.SYSTEM_ID = b.SYSTEM_ID
			and		a.LISTID    = b.LISTID
			where a.SYSTEM_ID = '{@SYSTEM_ID}'
			and  a.DYUPD is not null
			and  a.FGKAN = '2'
			and  a.FGJ   = '1'
			and  a.PGUPD != 'REP01'
			<og:where startKey="and">
				<og:and value = "a.JOKEN    LIKE '{@JOKEN}'"      />
				<og:and value = "a.LISTID   LIKE '{@LISTID}'"     />
				<og:and value = "a.DMN_NAME LIKE '{@DMN_NAME}'"   />
				<og:and value = "'{@DYSETFROM}000000' <= a.DYSET"  />
				<og:and value = "a.DYSET <= '{@DYSETTO}999999'"    />
			</og:where>
			order by a.SYSTEM_ID,a.LISTID,a.JOKEN,a.DMN_NAME,a.DYSET DESC,a.DYUPD DESC
		)
		group by {@CLM_LISTID} {@CLM_JOKEN} {@CLM_DMN_NAME} {@CLM_DYSET} SYSTEM_ID
	</og:value>
</og:equals>

<og:equals val1="{@ACTION}" val2="MEISAI" >
	<og:value key="SQL" >
		select SYSTEM_ID,LISTID,LISTNAME,JOKEN,DMN_NAME,DYSET,DYUPD,SUDATA,round(TMDIFF,1) as TMDIFF
		from (
			select a.SYSTEM_ID,a.LISTID,b.LISTNAME,a.JOKEN,a.DMN_NAME,a.DYSET,a.DYUPD,
					DECODE(a.SUDATA,0,1,a.SUDATA) as SUDATA,
					(to_date( a.DYUPD,'YYYYMMDDHH24MISS' ) - to_date( a.DYSET,'YYYYMMDDHH24MISS' )) * 86400 as TMDIFF
			from    GE50 a left outer join GE54 b
			on		a.SYSTEM_ID = b.SYSTEM_ID
			and		a.LISTID    = b.LISTID
			where a.SYSTEM_ID = '{@SYSTEM_ID}'
			and  a.DYUPD is not null
			and  a.FGKAN = '2'
			and  a.FGJ   = '1'
			and  a.PGUPD != 'REP01'
			<og:where startKey="and">
				<og:and value = "a.JOKEN    LIKE '{@JOKEN}'"      />
				<og:and value = "a.LISTID   LIKE '{@LISTID}'"     />
				<og:and value = "a.DMN_NAME LIKE '{@DMN_NAME}'"   />
				<og:and value = "'{@DYSETFROM}000000' <= a.DYSET"  />
				<og:and value = "a.DYSET <= '{@DYSETTO}999999'"    />
			</og:where>
			order by a.SYSTEM_ID,a.LISTID,a.JOKEN,a.DMN_NAME,a.DYSET DESC,a.DYUPD DESC
		)
	</og:value>
</og:equals>
