
你应该这样写SQL:
select a.*,b.人员 from A a,B b
where a.fid=b.minid
and (a.type='全部' or (a.type='部分' and a.minid=这里需要你传当前 *** 作人员的ID作为条件))
这样写的意思是显示全部及当前 *** 作人员ID的记录,如果你不选择 *** 作员,那么只显示全部的记录,否则,即显示全部及当前 *** 作人员ID相同的记录。
你好:(1)首先,请确认表名称正确,且“aaa.”及“t1.”后面跟随的表字段都存在
(2)“aaa.accoamount =”这里直接用等于号是不恰当的
可以将“aaa.accoamount”后面的“=”改为“in”运行
(3)再考虑到效率问题,将in用exists替换,可以改为如下语句:
select * from CDBCFA_TMP_EXDEBT_AS aaa where aaa.bustype = 'AN'
and exists (select t1.accoamount
from CDBCFA_TMP_EXDEBT_AS t1
where t1.bustype = 'AN'
and t1.chdate <aaa.chdate --前次变动日期需小于这次变动的日期
and t1.exdebtcode = aaa.exdebtcode
order by t1.chdate desc
where rownum = 1--这里请问rownum是属于哪张表中的,请标明后运行
and aaa.accoamount = t1.accoamount)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)