update x
set 水费=a2.水费
from a2,a1 x
where a2.代码=a1.代码
and x.户名=(select min(户名) from a1 where 代码=x.代码)