<?xml version="1.0" encoding="UTF-8"?>
<!--
     $Author: Hand.pc
    $Date: 2019-1-7 15:07:02
    $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-->
            <!--TO_CHAR(fdate, 'yyyy-mm') field,-->
            <!--to_number(TO_CHAR(fdate, 'mm')) no-->
            <!--FROM-->
            <!--(SELECT-->
            <!--fdate-->
            <!--FROM-->
            <!--(SELECT-->
            <!--to_date(${@year}-->
            <!--|| '-'-->
            <!--|| lpad(LEVEL, 2, 0), 'yyyy-mm') AS fdate-->
            <!--FROM-->
            <!--dual CONNECT BY LEVEL <= 12-->
            <!--) t-->
            <!--)-->
            <!--]]></bm:query-sql>-->
            <bm:query-sql><![CDATA[
             SELECT year_month field,
            year_seq,
            to_number(month_num) no
            FROM (SELECT year_num ||'-'|| month_num year_month,
            month_num,
            year_num,
            decode(year_num-${@year},0,'first',1,'second',2,'third') year_seq
            FROM (SELECT lpad(LEVEL, 2, 0) month_num
            FROM dual
            CONNECT BY LEVEL <= 12) t1,
            (SELECT (${@year} + level - 1) year_num
            FROM dual
            CONNECT BY LEVEL <= 3) t2)
            order by year_month
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
