<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hp  
    $Date: 2015-2-15 上午11:40:54  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
          SELECT *
  FROM (SELECT DISTINCT (SELECT bal.province_id_n
                           FROM hls_bp_master_address_lv bal,
                                con_contract_bp          cb
                          WHERE cb.bp_id = bal.bp_id
                            AND cb.contract_id = cc.contract_id
                            AND cb.bp_id = cc.bp_id_tenant
                            and bal.province_id is not null
                            AND cb.bp_category = 'TENANT'
                            AND cb.enabled_flag = 'Y'
                            AND bal.enabled_flag = 'Y'
                            AND rownum = 1) province_id_tenant_n,
                        nvl((SELECT '#' || bal.province_id
                              FROM hls_bp_master_address_lv bal,
                                   con_contract_bp          cb
                             WHERE cb.bp_id = bal.bp_id
                               AND cb.contract_id = cc.contract_id
                               AND cb.bp_id = cc.bp_id_tenant
                               and bal.province_id is not null
                               AND cb.bp_category = 'TENANT'
                               AND cb.enabled_flag = 'Y'
                               AND bal.enabled_flag = 'Y'
                               AND rownum = 1),
                            '##') province_id
        
          FROM con_contract cc
         WHERE 1 = 1
           AND cc.data_class = 'NORMAL'
           AND cc.contract_status = 'TERMINATE'
    and nvl(cc.hd_user_col_v10,'N') = 'N'
    and cc.division in ('20')) tt
 ORDER BY tt.province_id
             ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="province_id"/>
        <bm:field name="province_id_tenant_n"/>
    </bm:fields>
</bm:model>
