后台数据库oracle8i里,有一张表
xh 序号
je 金额
rq 日期
只是模拟一下表的情况。现在做的项目,要求在前台一张表里显示同一序号的当月金额,上月金额,去年本月金额。
xh rq je rq je rq je
序号 当前日期 金额 上月日期 上月金额 去年此时 去年此时金额
请问,如何实现??????
xh 序号
je 金额
rq 日期
只是模拟一下表的情况。现在做的项目,要求在前台一张表里显示同一序号的当月金额,上月金额,去年本月金额。
xh rq je rq je rq je
序号 当前日期 金额 上月日期 上月金额 去年此时 去年此时金额
请问,如何实现??????
select xh,rq,je,
(
select b.je
from table b
where b.xh=a.xh
and b.rq=""/上月日期
) as last_month_je,
(
select
from table c
where c.xh=a.xh
and c.rq="/上年日期"
) as last_year_je
from table a
where ...