<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-3-12 下午01:05:43  
    $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 pl.fin_statement_type,
       pl.fin_statement_item,
       pl.line_number,
       sum(decode(ph.fiscal_year,
                  (select min(d.fiscal_year)
                     from rsc_fin_statement_prj_hds d
                    where d.fin_statement_templet_id =
                          ph.fin_statement_templet_id),
                  pl.amount)) as min_fiscal_year_amount,
       sum(decode(ph.fiscal_year,
                  (select min(d.fiscal_year)
                     from rsc_fin_statement_prj_hds d
                    where d.fin_statement_templet_id =
                          ph.fin_statement_templet_id) + 1,
                  pl.amount)) as second_fiscal_year_amount,
       sum(decode(ph.fiscal_year,
                  (select min(d.fiscal_year)
                     from rsc_fin_statement_prj_hds d
                    where d.fin_statement_templet_id =
                          ph.fin_statement_templet_id) + 2,
                  pl.amount)) as third_fiscal_year_amount,
       sum(decode(ph.fiscal_year,
                  (select max(d.fiscal_year)
                     from rsc_fin_statement_prj_hds d
                    where d.fin_statement_templet_id =
                          ph.fin_statement_templet_id),
                  pl.amount)) as max_fiscal_year_amount
  from rsc_fin_statement_prj_hds ph, rsc_fin_statement_prj_lns pl
 where ph.fin_statement_id = pl.fin_statement_id
   and pl.fin_statement_type = '资产负债表'
   and ph.fin_statement_templet_id = 22
 group by pl.fin_statement_type, pl.fin_statement_item,pl.line_number
 order by pl.line_number]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
