3、VD' when4then'CD' else'Magazine' end fromproducts 结果: PRODUCT_IDPRODUCT_TYPE_IDCASEPROD --------------------------------- 1 1 Book 2 1 Book 3 2
4、 Video 4 2 Video 5 2 Video 6 2 Video 7 3 DVD 8 3 DVD 9 4
5、 CD 10 4 CD 11 4 CD 12 Magazine 12rowsselected. 2.搜索CASE表达式,使用条件确定返回值. 语法: CASE WHENcondition1THENresult1 WHENcon
6、distion2THENresult2 ... WHENcondistionNTHENresultN ELSEdefault_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