标签:style cas 双引号 log acl 查询 table sel 语句
例子1:
a)查询列中有"_"开头的列名时,需要用双引号引起来。
b)使用"case"关键字,根据分数直接判断是否及格。
create table tbl_score( id NUMBER(4), --id name varchar2(30), --名称 score NUMBER(3), --分数 otherscore NUMBER(3) --其他分数 );
select t.id as "_id", t.name as name, case when t.score >= 60 then ‘及格‘ else ‘不及格‘ end as ‘是否及格‘, t.score as ‘分数‘
from tbl_score t;
例子2:
根据情况返回不同列的值。
同用上面的tbl_score表。
select t.id as "_id", t.name as name, case when t.score is null then t.otherscore --也可返回固定值 else t.score end as ‘分数‘ from tbl_score t;
标签:style cas 双引号 log acl 查询 table sel 语句
原文地址:http://www.cnblogs.com/zj0208/p/6208692.html