zoukankan      html  css  js  c++  java
  • 表中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选择C列

    if object_Id('testTb')is not null drop table testTb
    go
    create table testTb (A int , B int ,C int)
    insert into testTb
    select 1,2,3 union all
    select 1,3,2 union all
    select 2,1,3 union all
    select 3,1,4

    select
         (case when A > B then A else B end) as E,
         (case when B > C then B else C end) as F
    from testTb
    drop table testTb

  • 相关阅读:
    个人总结
    团队作业五
    个人项目五:个人回顾
    第二次冲刺
    第一次冲刺
    猜数字1
    随机数
    个人作业
    课后作业1
    作业
  • 原文地址:https://www.cnblogs.com/aisini/p/1688445.html
Copyright © 2011-2022 走看看