select accnt_date,a.mem_code as mem_code,sum(case when b.deposit_type='01' then 1 else 0 end) as zdbzj_cs,
sum(case when b.deposit_type='01' and cur_accnt_code ='10' then net_amnt else 0 end ) as zdbaj_rmb,
sum(case when b.deposit_type='01' and cur_accnt_code ='14' then net_amnt else 0 end ) as zdbaj_my,
sum(case when b.deposit_type='02' and trade_sum>0 then 1 else 0 end) as bdbzj_cs,
sum(case when b.deposit_type='02' and trade_sum>0 and cur_accnt_code ='10' then net_amnt else 0 end ) as bdbaj_rmb,
sum(case when b.deposit_type='02' and trade_sum>0 and cur_accnt_code ='14' then net_amnt else 0 end ) as bdbaj_my,
sum(case when b.deposit_type='02' and trade_sum_2>0 then 1 else 0 end) as cebdbzj_cs,
sum(case when b.deposit_type='02' and trade_sum_2>0 and cur_accnt_code ='10' then net_amnt else 0 end ) as cebdbaj_rmb,
sum(case when b.deposit_type='02' and trade_sum_2>0 and cur_accnt_code ='14' then net_amnt else 0 end ) as cebdbaj_my
from fx_dp_changebal a,fx_bzj_wlz b
where
#where1#
and (a.next_usd_add<>0 or a.next_cny_add<>0)
and #where2#
and a.add_date = b.accnt_date and a.mem_code = b.mem_code
and b.sf_flag='1'
group by accnt_date,a.mem_code
order by accnt_date,a.mem_code请各位帮忙看下这个sql,在DB2中执行成功,但在程序中老是报a.mem_code上下文使用无效,这是哪门子的问题呀。谢谢。
sum(case when b.deposit_type='01' and cur_accnt_code ='10' then net_amnt else 0 end ) as zdbaj_rmb,
sum(case when b.deposit_type='01' and cur_accnt_code ='14' then net_amnt else 0 end ) as zdbaj_my,
sum(case when b.deposit_type='02' and trade_sum>0 then 1 else 0 end) as bdbzj_cs,
sum(case when b.deposit_type='02' and trade_sum>0 and cur_accnt_code ='10' then net_amnt else 0 end ) as bdbaj_rmb,
sum(case when b.deposit_type='02' and trade_sum>0 and cur_accnt_code ='14' then net_amnt else 0 end ) as bdbaj_my,
sum(case when b.deposit_type='02' and trade_sum_2>0 then 1 else 0 end) as cebdbzj_cs,
sum(case when b.deposit_type='02' and trade_sum_2>0 and cur_accnt_code ='10' then net_amnt else 0 end ) as cebdbaj_rmb,
sum(case when b.deposit_type='02' and trade_sum_2>0 and cur_accnt_code ='14' then net_amnt else 0 end ) as cebdbaj_my
from fx_dp_changebal a,fx_bzj_wlz b
where
#where1#
and (a.next_usd_add<>0 or a.next_cny_add<>0)
and #where2#
and a.add_date = b.accnt_date and a.mem_code = b.mem_code
and b.sf_flag='1'
group by accnt_date,a.mem_code
order by accnt_date,a.mem_code请各位帮忙看下这个sql,在DB2中执行成功,但在程序中老是报a.mem_code上下文使用无效,这是哪门子的问题呀。谢谢。
#where1#
#where2#
是什么东东?在oracle中不能识别!
select accnt_date,
a.mem_code as mem_code,
sum(case
when b.deposit_type = '01' then
1
else
0
end) as zdbzj_cs,
sum(case
when b.deposit_type = '01' and cur_accnt_code = '10' then
net_amnt
else
0
end) as zdbaj_rmb,
sum(case
when b.deposit_type = '01' and cur_accnt_code = '14' then
net_amnt
else
0
end) as zdbaj_my,
sum(case
when b.deposit_type = '02' and trade_sum > 0 then
1
else
0
end) as bdbzj_cs,
sum(case
when b.deposit_type = '02' and trade_sum > 0 and
cur_accnt_code = '10' then
net_amnt
else
0
end) as bdbaj_rmb,
sum(case
when b.deposit_type = '02' and trade_sum > 0 and
cur_accnt_code = '14' then
net_amnt
else
0
end) as bdbaj_my,
sum(case
when b.deposit_type = '02' and trade_sum_2 > 0 then
1
else
0
end) as cebdbzj_cs,
sum(case
when b.deposit_type = '02' and trade_sum_2 > 0 and
cur_accnt_code = '10' then
net_amnt
else
0
end) as cebdbaj_rmb,
sum(case
when b.deposit_type = '02' and trade_sum_2 > 0 and
cur_accnt_code = '14' then
net_amnt
else
0
end) as cebdbaj_my
from fx_dp_changebal a, fx_bzj_wlz b
where --#where1#
(a.next_usd_add <> 0 or a.next_cny_add <> 0)
--and #where2#
and a.add_date = b.accnt_date
and a.mem_code = b.mem_code
and b.sf_flag = '1'
group by accnt_date, a.mem_code
order by accnt_date, a.mem_code
你看看 fx_dp_changebal 有mem_code这字段么?
order by 的那个字段也标上 别名.字段
#where1#
这个是什么意思你把语句里面的字段都加上所属表的别名