在SQL,怎么把列表中的数值10,20,30,40转为小学,初中,高中,用什么语句写?

来源:百度知道 编辑:UC知道 时间:2024/07/07 06:46:49
在SQL,怎么把列表中的数值10,20,30,40转为小学,初中,高中,用什么语句写?
加一句用的是SQL查询分析器语句

select case columnname when '10' then '小学' when '20' then '初中' when '30' then '高中' when '40' then '大学' end from tablename

//基本一楼的答案很正确了,有点小问题,我补充下
select case columnname(原来的列名) when '10' then '小学' when '20' then '初中' when '30' then '高中' when '40' then '大学' end as newcolumnname (新的列名) from tablename where columnname in ('10','20','30','40')
对不住一楼了,呵呵,借用了他的代码