select distinct
    baadr.agent_id,
    baadr.dialogs_id,
    baadr.member_id,
    baadr.content,
    baadr.`timestamp`
from
    biz_agent_application_dialogues_record baadr
join biz_data_analyze_dialogue_record bdadr
    on bdadr.relation_id = baadr.agent_id
    and  bdadr.member_id = baadr.member_id
    and bdadr.channel ='index'
where baadr.is_deleted ='N'
    << and baadr.member_id= :memberId>>
group by baadr.dialogs_id
order by baadr.`timestamp` desc