select title_id
CASE SUBSTRING(title_id,1,2),
when 'BU' then 'business'
when 'MC' then 'Modern Cooking'
when 'PC' then 'Popular Computing'
when 'PS' then 'Psychology'
when 'TC' then 'Traditional Cooking'
END AS BookType
from titles
服务器: 消息 156,级别 15,状态 1,行 2
在关键字 'CASE' 附近有语法错误。
也看过了case的具体用法,还是找不出什么问题!帮忙,谢谢啦!
CASE SUBSTRING(title_id,1,2),
when 'BU' then 'business'
when 'MC' then 'Modern Cooking'
when 'PC' then 'Popular Computing'
when 'PS' then 'Psychology'
when 'TC' then 'Traditional Cooking'
END AS BookType
from titles
服务器: 消息 156,级别 15,状态 1,行 2
在关键字 'CASE' 附近有语法错误。
也看过了case的具体用法,还是找不出什么问题!帮忙,谢谢啦!
解决方案 »
- sql 统计查询问题
- 求多表联合汇总的一句SQL语句
- 请教如果在使用2-N个"IN"子句查询的时候从结果集中检索符合标准的记录?
- 几个客户端登陆访问SQL SERVER,且都以同一用户(sa)访问SQL SERVER,SQL SERVER知不知道有几个客户端在访问,怎么获取?
- 菜鸟求助sql语句!!!
- 中文版SQL Server 2000开发与管理应用实例,邹老大的书,让邹老大来个EBOOK吧……
- 怎么在这里转换成文本格式,并在前面加个0,哪位高手指点一下呀。
- 怎样清除temp的日志?
- 在查询分析器里执行的sql语句中的日期是2006-9-8,插入到表中却变成了1905-06-22 00:00:00.000。为什么呢?
- 分组后进行排序求助
- 单据流水号问题
- 服务器: 消息 7983,级别 14,状态 8,行 1
CASE
when SUBSTRING(title_id,1,2)='BU' then 'business'
when SUBSTRING(title_id,1,2)='MC' then 'Modern Cooking'
when SUBSTRING(title_id,1,2)='PC' then 'Popular Computing'
when SUBSTRING(title_id,1,2)='PS' then 'Psychology'
when SUBSTRING(title_id,1,2)='TC' then 'Traditional Cooking'
END AS BookType
from titles
CASE SUBSTRING(title_id,1,2)
when 'BU' then 'business'
when 'MC' then 'Modern Cooking'
when 'PC' then 'Popular Computing'
when 'PS' then 'Psychology'
when 'TC' then 'Traditional Cooking'
END AS BookType
from titles
CASE SUBSTRING(title_id,1,2)
when 'BU' then 'business'
when 'MC' then 'Modern Cooking'
when 'PC' then 'Popular Computing'
when 'PS' then 'Psychology'
when 'TC' then 'Traditional Cooking'
END AS BookType
from titles
帅哥,你最后加一个逗号干嘛???
CASE ... WHEN ... THEN ... ELSE ... END