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

怎么根据统计出来的次数来改变标志位字段?

如图,现在统计出每个药品的订货次数times,现在想根据times>=2的把IScommon变为true,times<2的IScommon变为false
应该怎么写SQl语句呢?

------解决方案--------------------
SQL code
update tb set iscommon=case when times>=2 then true when times<2 then false else NULL END

------解决方案--------------------
SQL code
;with t as
(
--你的统计语句
)
update t set iscommon=case when times>=2 then 'true' else 'false' end