首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

想把两句sql合为一句,该怎么解决

2012-09-11 
想把两句sql合为一句请问怎么把下面的语句合为一句呢?谢谢Declare @cje MoneySelect @cjeSum((isnull(jh_

想把两句sql合为一句
请问怎么把下面的语句合为一句呢?谢谢

Declare @cje Money

Select @cje=Sum((isnull(jh_qty,0)-Isnull(xs_qty,0))*Sp_jhdj) From spjinhuo Where jh_qty>xs_qty and sp_tm='300002'

update SpKuCun set kcdj=@cje/kcsl where kctm='300002'


[解决办法]

SQL code
update SpKuCun set kcdj=(Select Sum((isnull(jh_qty,0)-Isnull(xs_qty,0))*Sp_jhdj)                          From spjinhuo                          Where jh_qty>xs_qty and sp_tm='300002')/kcsl where kctm='300002'
[解决办法]
SQL code
update SpKuCun set kcdj=(Select Sum((isnull(jh_qty,0)-Isnull(xs_qty,0))*Sp_jhdj)                 From spjinhuo                    Where jh_qty>xs_qty and sp_tm='300002')/kcsl --直接把@cje替换掉where kctm='300002' 

热点排行
Bad Request.