日期:2014-05-18  浏览次数:20552 次

Insert Into时,需要计算一个值,但是当值小于5时,就插入5怎么办?
一个语句是:

insert into a (feiyong) values(zijin * feilv);

但是当zijin*feilv小于5时,按5插入,怎么办?



------解决方案--------------------
SQL code
insert into a (feiyong) 
select case when zijin * feilv <5 then 5 else zijin * feilv end

------解决方案--------------------
SQL code
insert into a (feiyong) 
select case when zijin * feilv < 5 then 5 else zijin * feilv end

------解决方案--------------------
SQL code
insert into a (feiyong) values(case when zijin * feilv<5 then 5 else zijin * feilv end)