2013-05-02 57 views
0

我需要將一個case語句放在一個字符串中。這怎麼能實現?在一個字符串中使用case語句

select DATEDIFF(MM, select CASE FA.new_ownertype 
     WHEN 8 then FA.new_vlenrollmentstartdate 
     ELSE FA.new_contractstartdate from BingMapsPlatform_Stagging.dbo.FilteredAccount as FA 
     END, GETDATE()) 

回答

4
select DATEDIFF(MM, 
    CASE FA.new_ownertype 
    WHEN 8 then FA.new_vlenrollmentstartdate 
    ELSE FA.new_contractstartdate 
    END, GETDATE()) 
from BingMapsPlatform_Stagging.dbo.FilteredAccount as FA 
相關問題