DB2的sql语句:
select a.op_date , plan_user_num,pre_plan_user_num ,ROUND(COALESCE(CAST(a.plan_user_num AS DOUBLE), 0)/a.pre_plan_user_num, 2) huanbi
from (select op_date,plan_user_num,(select plan_user_num from mtl_camp_evaluate_dm w where date(w.op_date) = date(t.op_date) - 1 day ) pre_plan_user_num from mtl_camp_evaluate_dm t order by t.op_date) a
查询结果:
op_date plan_user_num pre_plan_user_num huanbi
2010-07-21
|
188
|
[Null]
|
[Null]
|
2010-07-22
|
180
|
188
|
0.96
|
2010-07-23
|
200
|
180
|
1.11
|
2010-07-24
|
180
|
200
|
0.9
|
2010-07-25
|
160
|
180
|
0.89
|
阅读(1828) | 评论(0) | 转发(0) |