求 sql修改

sd_cobol 2011-01-19 09:54:14
select collacct.custid,
collacct.account,
collacct.cmbcflag,
collacct.accttype,
collacct.acctentpertype,
collacct.acctname,
collacct.currcode,
collacct.openbranchname,
collacct.openbranchaddr,
collacct.openbranchcode,
collacct.movtelno,
collacct.emailaddr,
collacct.pathcode,
collacct.bnkcode,
collacct.alisa,
collacct.remark,
collacct.recvcount,
collacct.wyhlbranchcode,
collacct.wyhlbranchname,
(select p.trancode
from note_pay p
where p.custid = collacct.custid
and p.payeracc = '4155990100000535'
and p.payeeacc = collacct.account) as trancode
from collacct collacct
WHERE collacct.custid = '1013989930'
and collacct.cmbcflag in ('1', '0')
and (collacct.account not in
(select payeeacc from note_pay where payeracc = '4155990100000535') or
account in (select payeeacc
from note_pay
where payeracc = '4155990100000535'
and flag = '1'))
order by collacct.recvcount desc

当collacct.cmbcflag 等于1的时候
要增加
((collacct.openbranchcode <> '' and
collacct.openbranchcode is not null) or collacct.cmbcflag='1')
or ((collacct.wyhlbranchcode <> '' and
collacct.wyhlbranchcode is not null) or collacct.cmbcflag='1')
过滤条件
...全文
65 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
aoli444 2011-01-19
  • 打赏
  • 举报
回复
select collacct.custid,
collacct.account,
collacct.cmbcflag,
collacct.accttype,
collacct.acctentpertype,
collacct.acctname,
collacct.currcode,
collacct.openbranchname,
collacct.openbranchaddr,
collacct.openbranchcode,
collacct.movtelno,
collacct.emailaddr,
collacct.pathcode,
collacct.bnkcode,
collacct.alisa,
collacct.remark,
collacct.recvcount,
collacct.wyhlbranchcode,
collacct.wyhlbranchname,
(select p.trancode
from note_pay p
where p.custid = collacct.custid
and p.payeracc = '4155990100000535'
and p.payeeacc = collacct.account) as trancode
from collacct collacct
WHERE collacct.custid = '1013989930'
and (collacct.account not in
(select payeeacc from note_pay where payeracc = '4155990100000535') or
account in (select payeeacc
from note_pay
where payeracc = '4155990100000535'
and flag = '1'))
and( collacct.cmbcflag ='0'
or
((collacct.openbranchcode <> '' and
collacct.openbranchcode is not null) and collacct.cmbcflag='1')
or ((collacct.wyhlbranchcode <> '' and
collacct.wyhlbranchcode is not null) and collacct.cmbcflag='1')

)

order by collacct.recvcount desc
qybao 2011-01-19
  • 打赏
  • 举报
回复
WHERE collacct.custid = '1013989930'
--and collacct.cmbcflag in ('1', '0')
and ( (collacct.cmbflag = '1' and (要追加的条件写在这里) )
or collacct.cmbflag = '0')
and (collacct.account not in
(select payeeacc from note_pay where payeracc = '4155990100000535') or
account in (select payeeacc
from note_pay
where payeracc = '4155990100000535'
and flag = '1'))
order by collacct.recvcount desc

sd_cobol 2011-01-19
  • 打赏
  • 举报
回复
写存储过程,改的太大
Nodin 2011-01-19
  • 打赏
  • 举报
回复
写存储过程呗

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧