<?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="cokr.xit.fims.crdn.dao.GlobalStngMapper">

<select id="selectBasicAmt" parameterType="cokr.xit.fims.crdn.CrdnQuery" resultType="string">
/* 기본금액 조회(globalStngMapper.selectBasicAmt) */
SELECT AMT
  FROM TB_AMT_INFO
 WHERE USE_YN = 'Y'
   AND TASK_SE_CD = #{taskSeCd}
   AND BGNG_YMD <![CDATA[ <= ]]> #{aplcnYmd}
   AND END_YMD <![CDATA[ >= ]]> #{aplcnYmd}
   <if test="amtDcsnCdGroupId != null">
   AND AMT_DCSN_CD_GROUP_ID = #{amtDcsnCdGroupId}
   AND AMT_DCSN_CD = #{amtDcsnCd}
   </if>
   <if test="dtlAmtDcsnCdGroupId != null">
   AND DTL_AMT_DCSN_CD_GROUP_ID = #{dtlAmtDcsnCdGroupId}
   AND DTL_AMT_DCSN_CD = #{dtlAmtDcsnCd}
   </if>
</select>

<select id="selectSggCd" parameterType="string" resultType="string">
/* 시군구코드 조회(globalStngMapper.selectSggCd) */
SELECT SGG_CD
  FROM TB_SGG_INFO
 WHERE INST_CD = #{institute}
</select>

<select id="selectStdgNmList" parameterType="string" resultType="string">
/* 법정동코드 목록 조회(globalStngMapper.selectStdgNmList) */
SELECT CONCAT(A.EMD_NM, 
       CASE WHEN A.LI_NM = ''
       THEN ''
       ELSE CONCAT(' ', A.LI_NM)
       END) AS STDG_NM
  FROM TB_STDG_INFO A
 WHERE A.STDG_CD LIKE CONCAT(#{sggCd},'%')
   AND A.STDG_CD != CONCAT(#{sggCd},'00000')
 ORDER BY A.EMD_NM, A.LI_NM
</select>

</mapper>