This WHERE clause finds a single row that has the same year,month,day,hour in another table.
It correctly counts 1 row.
SELECT count(*) FROM
dw.prints_by_hour_work w , dw.prints_by_hour h
WHERE
w.year = h.year
and w.month = h.month
and w.day = h.day
and w.hour = h.hour
The same join here, updates every row in the table which is incorrect.
update
dw.prints_by_hour
set
count = h.count + w.count
from
dw.prints_by_hour_work w , dw.prints_by_hour h
WHERE
w.year = h.year
and w.month = h.month
and w.day = h.day
and w.hour = h.hour
Is the join supported for UPDATE ?
If its supported then I can send the create statements etc so you can reproduce.