1.利用SqlServer中的case when来把数据查询出来的数据替换成其它值显示

2.结果对比:

 普通select查询出来的结果如下:

SQLServer2005 CASE WHEN在项目中实例-查询显示值替换

 用了case when方法后显示结果如下:

 SQLServer2005 CASE WHEN在项目中实例-查询显示值替换

3.具体使用代码如下:

 

select cInvCode,cValueType,
    case 
        when cValueType='全月平均法'  then 'S'
        when cValueType='计划价法'  then 'J'
        else ''
    end as cValueType
,isnull(iInvRCost,0) from Inventory


 作者:王春天 2013.11.11 地址:http://www.cnblogs.com/spring_wang/p/3418061.html

 

相关文章:

  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2021-12-17
  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案