當 a>b獲取a,不然獲取b,當a>c獲取a,不然獲取c,b大於c獲取b不然獲取cblog
SELECT id,(CASE WHEN a>b THEN a WHEN a>c THEN a WHEN b>c THEN b ELSE c END) as d FROM test2;test
SELECT id,(CASE WHEN a>30 THEN '三十' WHEN a>20 THEN '二十' WHEN a>10 THEN '十' ELSE '小於十' END) as d FROM test2;im