select
main.DATAROWNUM
, main.number_apply
, main.applicationCurrencyAmount
, main.exchangeRate
, main.applicationCurrency
, main.reimburseMan
, main.budgetStartDate
, main.apply_department
, main.loanAmount
, sum(journey.daysOfTravel) sumDays
, GROUP_CONCAT(journey.countries) countries
, GROUP_CONCAT(journey.placeOfTravel) placeOfTravel
, GROUP_CONCAT(DATE_FORMAT(journey.ToDate, '%Y-%m-%d')) ToDate
, main.solidification
from formdata_{tenantId}_${formId} main
left join formdata_{tenantId}_${formId}_journey journey on main.DATAROWNUM = journey.PARENTDATAROWNUM
where main.DELETEFLG = 0
and main.loanAmount > 0
and main.processState = 20
update apply_merge_{rule}
set data_start = 99
where group_id in (
select c.group_id from (
select group_id from apply_merge_{rule} where apply_id = #{dataRowNum} and data_start = 0
) c
)