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)这样不行

解决方案 »

  1.   

    item.DocNum = case when item.docnum is not null then 1 else item.DocNum end
    ORDR.DocNum = case when item.docnum is not null then 1 else ORDR.DocNum end拆开
      

  2.   


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

  3.   


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