在sqlserver数据库表中有字段A B C三个字段的数据,要求用sql

在sqlserver数据库表中有字段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 else c end)
from table_name
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-03-03
select case when A>B then A else B end ,
case when B>C then B else C end
from table
第2个回答  2011-03-03
select
case when A > B ZHEN A
case when B < A ZHEN B
case when B > C ZHEN B
CASE WHEN C>B ZHEN C
end
from 表名

你这个逻辑没问题?如果A,C都大于B那输出什么?
相似回答