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

求一条一句,先谢谢了
表1
bano,eqno,qty
ba,ea,100
ba,ed,100
bc,ea,50
be,ef,50
----------------------------

表2
bano,eqno,jhs,wcs
ba,ea,24,0
ba,ea,24,0
ba,ea,24,0
ba,ea,24,0
ba,ea,24,0
ba,ea,14,0
ba,ed,30,0
ba,ed,20,0
bc,ea,12,0
bc,ea,12,0
bc,ea,12,0
bc,ea,12,0
bc,ea,2,0
be,ef,24,0
be,ef,24,0
be,ef,24,0
be,ef,24,0
----------------------------
bano,eqno为varchar类型,jhs,wcs,qty为int类型


======================
需要下面结果
表2
bano,eqno,jhs,wcs
ba,ea,24,24
ba,ea,24,24
ba,ea,24,24
ba,ea,24,24
ba,ea,24,4
ba,ea,14,0
ba,ed,30,30
ba,ed,20,20
bc,ea,12,12
bc,ea,12,12
bc,ea,12,12
bc,ea,12,12
bc,ea,2,2
be,ef,24,24
be,ef,24,24
be,ef,24,2
be,ef,24,0



意思是说
当表2里的bano,eqno字段和表1相同 and 表1的qty > 0 时候修改表2中wcs字段(wcs字段数值不能大于表1的qty字段,同时也不能大于表2的jhs),修改表2wcs字段后,要将表1的qty-wcs






------解决方案--------------------
探讨

我使用的是SQL2000,游标怎么用呀