17,086
社区成员
发帖
与我相关
我的任务
分享
select
e.id,e.name,a.amount '1月',b.amount '2月',b.amount-a.amount '增加'
from
emp e,Business a,Business b
where
e.id=a.e_id
and
a.year=b.year and a.e_id=b.e_id
and
a.month='01' and b.month='02' and a.year='2007'
and
a.amount<b.amount
select a.id,a.name,c.jan,c.feb,c.feb-c.jul faise_amt
from emp a,
(
select e_id,sum(decode(month,1,amount,0)) jan,sum(decode(month,2,amount,0)) feb
from Business b
where year='2007'
and month in (1,2)
group by e_id
) c
where a.id=c.e_id
and c.feb-c.jan>0