这两天又试验了下,通过三句代码可以解决问题,目前还看不出问题所在,麻烦各位前辈给找找问题。
SELECT hwmc,MAX(jhj) as zdjhj FROM hwjgb WHERE qddj="A" GROUP BY hwmc INTO CURSOR aa &&找出qqdj为A的hwmc和其最大jhj
UPDATE hwjgb SET hwjgb.zgjhzdj=aa.zdjhj from aa WHERE ALLTRIM(hwjgb.hwmc)==ALLTRIM(aa.hwmc) &&更新货物名称与aa表完全相同的zgjhzdj
UPDATE hwjgb SET zgjhzdj=(select MAX(jhj) from hwjgb b WHERE hwjgb.hwmc==b.hwmc) from hwjgb WHERE zgjhzdj=0 &&更新qddj无“A”的所有货物的zgjhzdj