update DepartmentAppTemplate set maintenanceDepartId = (select id from OrgUnit where orgUnitCoding = (select po.orgUnitCoding from SupplyRoomConfig po where po.supplyRoomType = 1 and sequence = (select min(sequence) from SupplyRoomConfig where supplyRoomType = 1))) where maintenanceDepartId is null