<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Wed May 11 15:49:38 KST 2016-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="nlib.col.service.impl.RentDAO">

 	<select id="listRentMngOrg" parameterType="String" resultType="EgovMap">
		SELECT DISTINCT B.MNG_ORG_CD, C.DEPT_NM AS MNG_ORG_NM
		FROM (
			SELECT FILE_ID AS MASTER_ID
			FROM  PE_BOOK_LENT A
			JOIN PE_BOOK_LENT_FILE B ON (A.BOOK_LENT_ID = B.BOOK_LENT_ID)
			WHERE A.BOOK_LENTER_ID = #{masterId}  
			UNION  
			SELECT A.MASTER_ID
			FROM  PE_BOOK_LENT_RESERVE A
			WHERE A.RSRV_USER_ID = #{masterId} 
		) A
		JOIN RG_MASTER B ON (A.MASTER_ID = B.MASTER_ID)
		JOIN SM_DEPT C ON (B.MNG_ORG_CD = C.ORG_CD)
		ORDER BY C.DEPT_NM
 	</select>
    
</mapper>