select u.user_id,
u.nick_name,
u.creation_time,
to_char(wm_concat(distinct ur.role_id)) role_ids,
to_char(wm_concat(distinct um.menu_id)) menu_ids
from (select u.user_id, u.nick_name, max(um.creation_time) creation_time
from sys_user u
left join sys_user_menu um
on u.user_id = um.user_id
and um.del_flag = 0
left join sys_user_role ur
on ur.user_id = u.user_id
where u.del_flag = 0
and um.user_id is not null
and ur.role_id = #{roleId}
and u.nick_name like #{nickName} || '%'
and um.menu_id = #{menuId}
and um.creation_time >= #{creationTime[0]}
and #{creationTime[1]} >= um.creation_time
group by u.user_id, u.nick_name) u
left join sys_user_menu um
on u.user_id = um.user_id
and um.del_flag = 0
inner join sys_menu m
on m.menu_id = um.menu_id
and m.del_flag = 0
and m.menu_type in ('M', 'C')
left join sys_user_role ur
on ur.user_id = u.user_id
group by u.user_id, u.nick_name, u.creation_time
order by u.creation_time desc
select u.user_id,
to_char(wm_concat(distinct ur.role_id)) role_ids,
to_char(wm_concat(distinct um.menu_id)) menu_ids
from sys_user u
left join sys_user_role ur
on ur.user_id = u.user_id
left join SYS_USER_MENU um
on um.user_id = u.user_id
and um.del_flag = 0
where u.del_flag = 0
and u.user_id = #{userId}
group by u.user_id