sisibest

导航

更新表中字段

 UPDATE dbo.HotelPolicy  SET HPFactorMark=TB.MarkValue FROM
 
(select HPF.HPFRPolicyId AS ID ,ISNULL(SUM(POWER(2,HPF.HPFRPolicyId-1)),0) AS MarkValue
 FROM HotelPolicyFactorRelation  HPF
 inner join dbo.HotelPolicy  HP on HPF.HPFRPolicyId=HP.Id
 WHERE HPF.HPFRFactorId NOT IN (5,7,8,9)
 GROUP BY  HPF.HPFRPolicyId
) AS TB
 WHERE HotelPolicy.Id=TB.ID

posted on 2013-07-02 11:13  sisibest  阅读(159)  评论(0编辑  收藏  举报