表中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选择C列。
2017-01-09 16:37
405 查看
------------------------------------------
select (case when a>b then a else b end ),
(case when b>c then b esle c end)
from table_name
[sql]
view plain
copy
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
select (case when a>b then a else b end ),
(case when b>c then b esle c end)
from table_name
[sql]
view plain
copy
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
相关文章推荐
- 表中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列
- 表中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选择C列。
- SQL面试题:有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列
- SQL面试题:有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列
- SQL面试题: 数据库中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列 ,当B列大于C列时选择B列否则选择C列 ,
- 表中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选C
- 表中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选择C列
- 表中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选C
- sql语句怎样实现求在列中选择某些相同名称的行,对这些相同名称行的数据进行累加.
- Sql语句中同样实现关联和子查询选择策略
- 用一条SQL语句 查询出每门课程都大于80分的学生姓名" 的实现方式
- 我的oracle笔记一(sql语句方面) 选择自 okcai 的 Blog
- UNION,EXISTS,IN等在SQL语句中的灵活应用和场境的选择。
- SQL查询语句对象化的实现(C#)
- SQL语句导入导出大全 选择自 whchen 的 Blog
- 用sql语句实现按时间求累计值
- 如何用SQL语句实现精确搜索以及模糊搜索
- 海量数据实现分页的sql语句
- 用T-SQL语句实现SQL server与XLS,MDB等文件的数据交换
- SQL语句实现横排