早教吧 育儿知识 作业答案 考试题库 百科 知识分享

oracle关于条件判断有A,B2张表,用1条件来从A,B中选出数据,当1条件不满足时,用2条件选出数据。这样的SQL怎么写。

题目详情
oracle 关于条件判断
有A,B 2张表,用1条件来从A,B中选出数据,当1条件不满足时,用2条件选出数据。
这样的SQL怎么写。
▼优质解答
答案和解析
用decode函数例如select decode(字段名,'条件1','值1','条件2','值2',默认值') from 表名 或者 case when 如果是在pl/sql块中可以用 if 条件 then else if 条件 then end if;...