<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="kr.co.i4way.mapper.tibero.TiberoMapper">

<select id="getCCCUser" parameterType="hashmap" resultType="hashmap">
	<![CDATA[
		SELECT 
		* 
		FROM (SELECT A.USER_ID
							, B.USER_NM
							, A.ETCP_YMD
							, A.LVCO_YMD
							, A.LVCO_YN
							, B.CUSC_ORG_NO
							, B.AUTH_GRP_NO
							, B.HP_TN
							, B.EML_ADR
							, B.EE_YN
							, A.CTI_USE_YN
							, B.INLN_TN
							, B.USE_YN
							, B.CNSR_TCD
							, A.CTI_CNNC_USER_ID AS CTI_ID
							, A.WKHM_YN
							, B.AUTH_GRP_NO 
							, B.CUSC_ORG_NO
							,  (to_date(TO_CHAR(A.FIN_MDFY_TISMP, 'YYYYMMDD'), 'YYYYMMDD') - to_date( TO_CHAR(A.VBG_RGST_TISMP, 'YYYYMMDD'), 'YYYYMMDD')) AS MODIFY_DIFF 
							, TO_CHAR(A.VBG_RGST_TISMP, 'yyyymmddHH24miss') AS RGST_DT
							, TO_CHAR(A.FIN_MDFY_TISMP, 'yyyymmddHH24miss') AS MDFY_DT
							, A.FIN_UPDR_ID
				  FROM C0207_USER_ALTR_H A, C0207_USER_B B
				WHERE A.USER_ID = B.USER_ID
				AND A.FIN_MDFY_TISMP = (SELECT MAX(FIN_MDFY_TISMP)  AS FIN_MDFY_TISMP
													FROM C0207_USER_ALTR_H 
													WHERE TO_CHAR(FIN_MDFY_TISMP, 'YYYYMMDD') = TO_CHAR(sysdate, 'YYYYMMDD')
													)
				AND TO_CHAR(A.FIN_MDFY_TISMP, 'YYYYMMDD') = TO_CHAR(sysdate, 'YYYYMMDD')
				)
]]> 
	</select> 
</mapper>