<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: jack  
    $Date: 2014-6-9 下午2:04:16  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
 SELECT (SELECT b.description FROM hls_business_type b WHERE b.business_type = t1.business_type) business_type_name,
        (SELECT c.bp_name
           FROM prj_project_bp c
          WHERE t1.project_id = c.project_id(+)
                AND c.bp_category = 'TENANT'
                AND rownum < 2) tenant_name,
        (SELECT SUM(lt.original_asset_value)
           FROM prj_project_lease_item lt
          WHERE t1.project_id = lt.project_id(+)
          GROUP BY lt.project_id) original_asset_value_1,
        (SELECT decode(trunc(SUM(lt.original_asset_value) / 10000),
                       0,
                       to_char(round(SUM(lt.original_asset_value) / 10000,
                                     4),
                               '0.0000'),
                       round(SUM(lt.original_asset_value) / 10000,
                             4))
           FROM prj_project_lease_item lt
          WHERE t1.project_id = lt.project_id(+)
          GROUP BY lt.project_id) original_asset_value_2,
        (SELECT to_char(round(SUM(lt.original_asset_value),4),'FM999,999,999,990.00')
           FROM prj_project_lease_item lt
          WHERE t1.project_id = lt.project_id(+)
          GROUP BY lt.project_id) original_asset_value_fm,
        (SELECT SUM(lt.net_asset_value)
           FROM prj_project_lease_item lt
          WHERE t1.project_id = lt.project_id(+)
          GROUP BY lt.project_id) net_asset_value_1,
        (SELECT decode(trunc(SUM(lt.net_asset_value) / 10000),
                       0,
                       to_char(round(SUM(lt.net_asset_value) / 10000,
                                     4),
                               '0.0000'),
                       round(SUM(lt.net_asset_value) / 10000,
                             4))
           FROM prj_project_lease_item lt
          WHERE t1.project_id = lt.project_id(+)
          GROUP BY lt.project_id) net_asset_value_2,
          (SELECT to_char(round(SUM(lt.net_asset_value),4),'fm999,999,999,990.00')
           FROM prj_project_lease_item lt
          WHERE t1.project_id = lt.project_id(+)
          GROUP BY lt.project_id) net_asset_value_fm,
        t1.ref_v06 lease_get_method,
        t1.ref_v10 risk_measure,
        t1.*
   FROM prj_project t1
 #WHERE_CLAUSE#
  ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="project_id" queryExpression="t1.project_id=${@project_id}"/>
    </bm:query-fields>
</bm:model>