sql修改~

sd_cobol 2011-01-19 09:49:48
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')
过滤条件
...全文
69 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
sd_cobol 2011-01-19
  • 打赏
  • 举报
回复
OK 多谢
sd_cobol 2011-01-19
  • 打赏
  • 举报
回复
抱歉
要增加的过滤条件是
and ((collacct.openbranchcode <> '' and
collacct.openbranchcode is not null) )
or ((collacct.wyhlbranchcode <> '' and
collacct.wyhlbranchcode is not null))
zhaojianmi1 2011-01-19
  • 打赏
  • 举报
回复
当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')
sd_cobol 2011-01-19
  • 打赏
  • 举报
回复
collacct.cmbcflag 值 有可能是 0,1,或(0,1)
wwwwb 2011-01-19
  • 打赏
  • 举报
回复
WHERE collacct.custid = '1013989930'
and collacct.cmbcflag in ('1', '0')
and
(
(collacct.cmbcflag=0) or
(collacct.cmbcflag=1 and
((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')
))
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
wwwwb 2011-01-19
  • 打赏
  • 举报
回复
WHERE collacct.custid = '1013989930'
and collacct.cmbcflag in ('1', '0')
and
(
(collacct.cmbcflag=0) or
(collacct.cmbcflag=1 and
((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')
))
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
ACMAIN_CHM 2011-01-19
  • 打赏
  • 举报
回复
WHERE collacct.custid = '1013989930'
and collacct.cmbcflag in ('1', '0')
and
(
collacct.cmbcflag=1!=1
or
(
collacct.cmbcflag=1 and ((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')

)
)

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

5,889

社区成员

发帖
与我相关
我的任务
社区描述
IBM DB2 是美国IBM公司开发的一套关系型数据库管理系统,它主要的运行环境为UNIX(包括IBM自家的AIX)、Linux、IBM i(旧称OS/400)、z/OS,以及Windows服务器版本
社区管理员
  • DB2
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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