<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hp  
    $Date: 2015-2-15 上午11:30:59  
    $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 tt.termination_date,nvl(tt.province_id,'##') province_id,count(1)quantity from ( SELECT
 
  (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 cb.bp_category = 'TENANT'
      AND cb.enabled_flag = 'Y'
      AND bal.enabled_flag = 'Y'
      and bal.province_id is not null
      AND rownum = 1) province_id,
  nvl(substr(to_char(cc.termination_date, 'yyyy-mm'), 0, 7),'##') termination_date
 
   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
    
    group by tt.termination_date,tt.province_id
    order by tt.termination_date asc
           #WHERE_CLAUSE#
          ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="province_id"/>
        <bm:field name="quantity"/>
        <bm:field name="termination_date"/>
    </bm:fields>
</bm:model>
