sql面试题

SQL面试题:有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列

原文地址
http://blog.csdn.net/u012110719/article/details/47133167
关于case的用法
http://www.cnblogs.com/Richardzhu/p/3571670.html

drop table table1  
create table table1(  
    a int,  
    b int,  
    c int  
)  
insert into table1 values(22,24,23)  

select * from table1  

select (case when a>b then a else b end),(case when b>c then b else c end)  
from table1  

select (case when a>b then a  
             when a>c then a  
             when b>c then b else c  
             end)  
from table1  
上一篇:when条件判断


下一篇:图解面试题:如何按条件修改数据?