最近在项目中遇到了一个sql语句难题,查看了资料才知道sql语句确实很强大。select case 写法如下:
select case
when a.ZHENGCSJJE > 0 then
(a.ZHENGCSJJE/a.ZHENGCJYBS)/100
when a.KEYJYBS > 0 then
(a.KEYSJJE/a.KEYJYBS)/100
when a.TIAOZJYBS > 0 then
(a.TIAOZSJJE/a.TIAOZJYBS)/100
else
0
end price from tablename a