【面试题】mysql 查询 a大于b输出a,b大于c输出c

1.方案一:
select 
    (case when a>b then a else b end ),
    (case when b>c then b esle c end)  
    from 表名

2.方案二:
select if(a>b,a,b),if(b>c,b,c) from 表名

附:存储过程的问题

创建存储过程 

create procedure proc_group  
@A  int,  --定义参数  
@B int,   @C int,
as   
BEGIN
*****************
7.end

 
查询:exec 存储过程名  参数1,参数2,参数3

删除:drop procedure 存储过程名  

猜你喜欢

转载自demonli.iteye.com/blog/2365191