现在的位置: 首页 > 综合 > 正文

sql 语句中的CASE 用法

2013年09月22日 ⁄ 综合 ⁄ 共 469字 ⁄ 字号 评论关闭

create table hu(

   Name varchar2(22),    
     sal number        

);
select * from hu;
insert into hu values('java',2300);
insert into hu values('shenzhen,6000);
insert into hu values('huhu',6700);
insert into hu values('huhu',670);
insert into hu values('jia,1800);

--------------------------------------------------------

select h.* ,
   case
    when sal<2000 THEN 'NO'
   else '不錯'   

end as stu from hu h;

------------------------------------------------------

语法:

     

case   where     then  end   

 

连着一起用。  else 是可选的。

 

 

 

 

 

 

抱歉!评论已关闭.