2、ressionNTHENresultN ELSEdefault_result END 例: selectproduct_id,product_type_id, caseproduct_type_id when1then'Book' when2then'Video' when3then'DVD' when4then'CD' else'Magazine' end fromproducts 结果: PRODUCT_IDPRODUCT_TYPE_IDCASEPROD -----------
3、---------------------- 1 1 Book 2 1 Book 3 2 Video 4 2 Video 5 2
4、 Video 6 2 Video 7 3 DVD 8 3 DVD 9 4 CD 10 4
5、 CD 11 4 CD 12 Magazine 12rowsselected. 2.搜索CASE表达式,使用条件确定返回值. 语法: CASE WHENcondition1THENresult1 WHENcondistion2THENresult2 ... WHENcondistionNTHENresultN ELSE
6、default_result END 例: selectproduct_id,product_type_id, case whenproduct_type_id=1then'Book' whenproduct_type_id=2then'Video' whenproduct_type_id=3then'DVD' whenproduct_type_id=4then'CD' else'Magazine' end fromproducts 结果与上相同.