oraclecasewhen用法

上传人:xiao****1972 文档编号:84085183 上传时间:2019-03-02 格式:DOC 页数:3 大小:21.50KB
返回 下载 相关 举报
oraclecasewhen用法_第1页
第1页 / 共3页
oraclecasewhen用法_第2页
第2页 / 共3页
oraclecasewhen用法_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《oraclecasewhen用法》由会员分享,可在线阅读,更多相关《oraclecasewhen用法(3页珍藏版)》请在金锄头文库上搜索。

1、Oracle case when用法1、以CASE开头,以END结尾2、分支中WHEN 后跟条件,THEN为显示结果3、ELSE 为除此之外的默认情况,类似于高级语言程序中switch case的default,可以不加4、END 后跟别名CASE有两种表达式:1. 简单CASE表达式,使用表达式确定返回值.语法:CASE search_expressionWHEN expression1 THEN result1WHEN expression2 THEN result2.WHEN expressionN THEN resultNELSE default_resultEND例:select p

2、roduct_id,product_type_id,case product_type_idwhen 1 then Bookwhen 2 then Videowhen 3 then DVDwhen 4 then CDelse Magazineendfrom products结果:PRODUCT_ID PRODUCT_TYPE_ID CASEPROD- - -1 1 Book2 1 Book3 2 Video4 2 Video5 2 Video6 2 Video7 3 DVD8 3 DVD9 4 CD10 4 CD11 4 CD12 Magazine12 rows selected.2. 搜索C

3、ASE表达式,使用条件确定返回值.语法:CASEWHEN condition1 THEN result1WHEN condistion2 THEN result2.WHEN condistionN THEN resultNELSE default_resultEND例:select product_id,product_type_id,casewhen product_type_id=1 then Bookwhen product_type_id=2 then Videowhen product_type_id=3 then DVDwhen product_type_id=4 then CDelse Magazineendfrom products结果与上相同.

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号