sql 查询面试题

    技术2022-05-19  29

    --表中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选择C列if object_Id('testTb')is not null drop table testTbgocreate table testTb (A int , B int ,C int)insert into testTbselect 1,2,3 union allselect 1,3,2 union allselect 2,1,3 union allselect 3,1,4--答案select A,B,C,     (case when A > B then A else B end) as D,     (case when B > C then B else C end) as Efrom testTbdrop table testTb


    最新回复(0)