SqlServer Case when then用法总结

SELECT d.DicName ,  --DevelopMode
ISNULL(NULL,NULL) ,  --Orgid
b.FullName ,  --Areid
c.DicName ,  --InvestProperty
f.DicName , --TwoProperty
PJName ,
PJLength ,
PJWidth  ,
UseArea ,
BuildArea ,
--IsSetUp as ,
CASE a.IsSetUp WHEN  0 THEN  '否'when 1 THEN '是'  END ,
--case when  '' like '%'+[BasePositionID] then 1 else 2 end  [BasePositionID] from SysPosition p 

CASE a.IsMeragr WHEN  0 THEN  '否'when 1 THEN '是' END ,
e.DicName
 FROM TopProjectNew a 
 INNER JOIN dbo.SysOrganization b ON a.AreaID=b.id
 INNER JOIN dbo.SysDictionary c ON a.InvestProperty =c.ID
 INNER JOIN dbo.SysDictionary d ON a.DevelopMode=d.ID
 INNER JOIN dbo.SysDictionary f ON a.TwoProperty=f.ID
 INNER JOIN dbo.SysDictionary e ON a.PJDomain=e.ID
 WHERE AreaID=''

'性别'=case Sex when 1 then '女' else '男' end


 

posted @ 2017-05-17 17:23  石shi  阅读(14228)  评论(0编辑  收藏  举报