數據庫中有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 表名
方法二:
select if(a>b,a,b),if(b>c,b,c) from 表名
數據庫中有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 表名
方法二:
select if(a>b,a,b),if(b>c,b,c) from 表名
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。