首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

Case When 的字段怎么作为条件

2013-01-11 
Case When 的字段如何作为条件?SELECT OrderNum(case when item.docnum is not null then item.DocNum el

Case When 的字段如何作为条件?


SELECT OrderNum=(case when item.docnum is not null then item.DocNum else ORDR.DocNum end).....
FROM  TB
INNER JOIN...
ON ...
WHERE 

我想把这个OrderNum 作为条件查询,需要怎么弄呢.,?
似乎


( case when item.docnum is not null then item.DocNum=1 else ORDR.DocNum=1 end)

这样不行
[解决办法]

( case when item.docnum is not null then item.DocNum else ORDR.DocNum end)=1

[解决办法]

SELECT .....
FROM  TB
INNER JOIN...
ON ...
WHERE (case when item.docnum is not null then item.DocNum else ORDR.DocNum end)=XX

热点排行