读书人

如何根据统计出来的次数来改变标志位字

发布时间: 2012-08-01 17:53:40 作者: rapoo

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

如图,现在统计出每个药品的订货次数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 

读书人网 >SQL Server

热点推荐