解决方案 »
- 是谁说的in不走索引?!
- sql语句求助,多谢了!
- begin transaction 开始但是没有正确提交或回滚后,其它session连select的权利都没有???!!!
- SQL Server 2008 (忽然就连接不上了,之前可以,诚恳求解)
- sql左连接 改成其他方式也能好用如何改?
- 如何将连续值字段的值重设为起始位置?(表已经清空)
- 在SQL server通過語句怎樣把數字轉換成英文
- 请问SQL Server 设置的链接服务器怎么样用ADO建立链接,谢谢
- 如何修改一个所属的表空间
- 如何select?
- Oracle有没有好的数据库监控工具呢,类似与SQLSERVER的SQLServerProfiler,监控Java程序每一步执行所产生的SQL语句?
- 跨数据库事务管控机制该如何处理,求具体思路
(select case when isnull(AppNo,'')<>'' then '已执行' else '未执行' end from OPA where appno=apply.appno) as '流程A',
(select case when isnull(AppNo,'')<>'' then '已执行' else '未执行' end from OPB where appno=apply.appno) as '流程B'
from apply
(select case when AppNo isnull then '已执行' else '未执行' end from OPA where appno=apply.appno) as '流程A',
(select case when AppNo isnull then '已执行' else '未执行' end from OPB where appno=apply.appno) as '流程B'
from apply
is null 和<>'' 是有很大的区别的,你用这两种情况多试下结果就会发现的
select a.AppNo,a.ClientName,case when ISNULL(b.appno,'')<>'' then '已执行' else '未执行' end as '流程A',
case when ISNULL(c.appno,'')<>'' then '已执行' else '未执行' end as '流程B',
from apply a left join opa b on a.appno=b.appno
left join opb c on a.appno=c.appno
case when ISNULL(c.appno,'')<>'' then '已执行' else '未执行' end as '流程B'
from apply a left join opa b on a.appno=b.appno
left join opb c on a.appno=c.appno
select AppNo,ClientName,
(select case when isnull(AppNo,'')<>'' then '已执行' else '未执行' end from OPA where appno=apply.appno) as '流程A',
(select case when isnull(AppNo,'')<>'' then '已执行' else '未执行' end from OPB where appno=apply.appno) as '流程B'
from apply
select AppNo,ClientName,
(select case when AppNo<>'' then '已执行' else '未执行' end from OPA where appno=apply.appno) as '流程A',
(select case when AppNo<>'' then '已执行' else '未执行' end from OPB where appno=apply.appno) as '流程B'
from apply--你的NULL值没处理
什么原因呢?
select * from OPb where appno is null看看是不是有数据
select AppNo,ClientName,
case when (select AppNo from OPA where appno=apply.appno)<>'' then '已执行' else '未执行' end as '流程A',
case when (select AppNo from OPB where appno=apply.appno)<>'' then '已执行' else '未执行' end as '流程B'
from apply标准的写法还是7L的好
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'),SERVERPROPERTY ('edition')
结果如下:
SQLServer2000 SP4 8.00.2039
目测不出原因,呵呵.但是我感觉这样写好怪啊··一般我是用Join的...不用这种写法
from
(select AppNo,ClientName,
(select case when isnull(AppNo,'')<>'' then '已执行' else '未执行' end from OPA where appno=apply.appno) as lca,
(select case when isnull(AppNo,'')<>'' then '已执行' else '未执行' end from OPB where appno=apply.appno) as lcb
from apply) a
如果必须要按照你的写法来,那就要想办法去掉null值了