UPDATE qna_table
SET
last_updated_user = last_update.user
FROM
(SELECT tmp.qna_id as id, tmp.user_ as user
  FROM (SELECT qna_id,  time, user_  FROM qna_state_change_table) tmp
  INNER JOIN
  (SELECT qna_id,  max(time) as last_timestamp FROM qna_state_change_table group by qna_id) last_update_time
  ON tmp.time = last_update_time.last_timestamp and tmp.qna_id = last_update_time.qna_id ) last_update
WHERE
qna_table.id = last_update.id;

