日期:2014-05-17 浏览次数:20673 次
with s as (
select "1季度" as name, 201201 as begin_month, 201204 as end_month from dual
union all
select "2季度" as name, 201201 as begin_month, 201207 as end_month from dual
union all
select "3季度" as name, 201201 as begin_month, 201210 as end_month from dual
union all
select "4季度" as name, 201201 as begin_month, 201301 as end_month from dual
)
select t.m_code, s.name, sum(t.q_receive) from table_a t, s
where t.p_id>=s.begin_month and t.p_id<s.end_month
group by t.m_code, s.name order by t.m_code, s.name;