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
表中有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
相关文章推荐
- 学术面试的10个常见问题
- 黑马程序员——— RuntimeException知识点
- ios 面试总结
- 一道SQL语句面试题,关于group by的
- 5年IT--职业迷茫
- 黑马程序员——Java面向对象(三)之内部类、异常、包等
- 2015年阿里巴巴校招客户端内推面试经历
- Java程序员常用工具集
- 前端开发面试题
- 不再是学生了,做好码农
- 黑马程序员——13,多线程(3)
- 【剑指Offer面试题】 九度OJ1515:打印1到最大的N位数
- 黑马程序员——java基础语法-判断语句、函数、数组
- 黑马程序员——Java基础——IO(二)
- Android面试题
- 面试题:谈谈如何优化MYSQL数据库查询
- 【剑指Offer面试题】 九度OJ1514:数值的整数次方
- 程序员如何爱护自己的眼睛
- 黑马程序员——高新技术---Java基础-反射
- 黑马程序员——java基础语法总汇关键字、常量、变量、语句、函数、数组