select * from ( select t.*,d.TABLE_NAME,d.QUERY_SQL,d.data_control_col,d.id table_id,d.where_sql
from REPORT_KPI_INFO t
left join REPORT_KPI_TABLE_INFO d
on t.id = d.kpi_id
where t.kpi_status=1
<if test="keyword != null and keyword != ''">
and t.id in
(select t.id
from REPORT_KPI_INFO t
start with t.id in (select t.id
from REPORT_KPI_INFO t
where t.kpi_name like '%'||#{keyword}||'%')
connect by t.id = prior t.parent_id)
union
select t.*,
d.TABLE_NAME,
d.QUERY_SQL,
d.data_control_col,
d.id table_id,
d.where_sql
from REPORT_KPI_INFO t
left join REPORT_KPI_TABLE_INFO d
on t.id = d.kpi_id
where t.kpi_status = 1
and t.id in
(select t.id
from REPORT_KPI_INFO t
start with t.id in (select t.id
from REPORT_KPI_INFO t
where t.kpi_name like '%'||#{keyword}||'%')
connect by prior t.id = t.parent_id)
</if>
)
order by to_number(kpi_sort)