码迷,mamicode.com
首页 > 其他好文 > 详细

select 中使用 case when 和 replace

时间:2016-06-03 01:07:26      阅读:642      评论:0      收藏:0      [点我收藏+]

标签:

在SELECT中,用CASE   
例如:   
  select   a.Cname   as   Tcomname,b.Cname   as   TGoodname,D.nQuanty,c.cNote,   (case   when   c.iEvaluate=‘-1‘  then   ‘差评‘  when   c.iEvaluate=‘1‘   then   ‘好评‘   when   c.ievaluate=‘0‘   then   ‘一般‘   end)   as   ievaluate     
  from   Tcompany   a,Tgoods   b,Appraise   c,orders   D   
  where   b.ID=D.nProductID   and   D.Id=c.order_id   and   a.Id=b.NsaID   
  and   b.NsaID=@TcomIDTop

 

select 和 replace
select AdID,replace(replace(cast(AdClassID as varchar(50)) ,‘0‘,‘头条新闻头部‘),‘1‘,‘头条新闻尾部‘) as AdClassID,Title,LinkUrl,UpdateTime from Advertisement order by AdID

 
 

select 中使用 case when 和 replace

标签:

原文地址:http://www.cnblogs.com/allonkwok/p/5554878.html

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!