您的位置:首页 > 职场人生

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

2015-07-29 20:21 309 查看
.请教一个面试中遇到的SQL语句的查询问题

表中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选择C列。

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

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

(case when b>c then b esle c end)

from table_name

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: