日期:2014-05-18  浏览次数:20523 次

这样的case语句能否用if。。。else替换??
select   s_number   as   学号,
                课程名称=case   c_number
                                  when   '20010201 '   then   'English '
                                    when   '20010202 '   then   'chinese '
                                  end
from   t_score
where.....
order....
如何替换,很郁闷,改不对总是。。

------解决方案--------------------
if else 不能放在语句当中
------解决方案--------------------

------解决方案--------------------
case when 和if then的相同之处在于他们都是条件控制语句,
但case when可当作函数使用,所以它能够用于表达式中,如等号后,
而if then没有这个功能,所以不能用于表达式中