日期:2014-05-17 浏览次数:20989 次
select t.*, t.rowid from D_MONTH_SALARY t;
select t.salarymonth,
sum(t.salary) / (select sum(t1.salary)
from D_MONTH_SALARY t1
where t1.salarymonth = (substr(t.salarymonth, 1, 4) - 1)
------解决方案--------------------
substr(t.salarymonth, -2)) "同比",
sum(t.salary) /
(select sum(t1.salary)
from D_MONTH_SALARY t1
where t1.salarymonth =
to_char(to_date(t.salarymonth, 'yyyymm') - 1, 'yyyymm')) "环比"
from D_MONTH_SALARY t
group by t.salarymonth;
/* Formatted on 2013/08/02 15:00 (Formatter Plus v4.8.7) */
SELECT t.salarymonth,
SUM (t.salary)
/ (SELECT SUM (t1.salary)