I got the following problem. I got two tables and want to move one column data to another table.
The tables are house and door. I want to move the column data 'street' to house. But there are multiple doors for the house (with same house_id). So I need to aggregate them and want to take the 'street' input from the newest 'created_at' record.
My first attempt is:
insert into house h ('street')
select street
from door d
where d.house_id = h.id
group by house_id
having max(created_at)