case when
1. 语法
- 简单函数
CASE [col_name] WHEN [value1] THEN [result1]…ELSE [default] END
- 搜索函数
CASE WHEN [expr] THEN [result1]…ELSE [default] END
2. 举例
- 例子
select nType,count(nType) as nCount,case nType when 1 then '图书' when 2 then '听书'when 3 then '视频' when 4 then '期刊' when 5 then '图片' when 6 then '精选' end as sBookType from TbCompanyBooks group by nType

网友评论