在oracle中如何实现以上的问题?例如有表: ADate AValue
2006-12-5 8
2007-1-1 10
2007-3-8 110
2007-5-10 18
..... 如何得到:
2006四季度 8
2007一季度 120
2007二季度 18
....
2006-12-5 8
2007-1-1 10
2007-3-8 110
2007-5-10 18
..... 如何得到:
2006四季度 8
2007一季度 120
2007二季度 18
....
group by trunc(t.adate,'Q')
group by to_char(t.adate,'Q')
group by to_char(ADate,'yyyy')||'年'||to_char(ADate,'q')||'季度'SELECT to_char(ADate,'yyyy')||'年'||to_char(ADate,'iw')||'周' as 周,sum(AValue) as total from tablename
group by to_char(ADate,'yyyy')||'年'||to_char(ADate,'iw')||'周'
SELECT to_char(ADate,'yyyy')||'年'||to_char(ADate,'mm')||'月'
|| case when to_char(ADate,'dd')<=10 then '上旬' when to_char(ADate,'dd')>20 then '下旬' else '中旬' end
as 旬,sum(AValue) as total from tablename
group by to_char(ADate,'yyyy')||'年'||to_char(ADate,'mm')||'月'
|| case when to_char(ADate,'dd')<=10 then '上旬' when to_char(ADate,'dd')>20 then '下旬' else '中旬' end