select h4.store_id,h3.crm_id,h2.role_name,h3.user_name from basic_role_user h1,basic_role h2,sys_user h3,basic_user_store h4
where h1.role_id=h2.role_id and h1.user_id=h3.id and h3.is_delete=0 and h3.crm_id=h4.user_id
and (h2.role_id=33201 or h2.role_id=33202) and h4.store_id in(
select
bcc.ORG_ID
from area a, basic_crm_channel bcc,sys_user m1,basic_role_user m2,basic_role m3 ,
basic_user_store ff where a.id=bcc.area_num
and ff.user_id=m1.crm_id and ff.store_id=bcc.ORG_ID
and bcc.channel_type=2 and bcc.is_display=0 and bcc.STATUS_CD=1000
and bcc.CHANNEL_CLASS=10 and m1.id=m2.user_id and m2.role_id=m3.role_id
and m1.is_delete=0 and m3.role_id=22205 GROUP BY a.id
) ;
---;
select h4.store_id,h3.crm_id,h2.role_name,h3.user_name from basic_role_user h1,basic_role h2,sys_user h3,basic_user_store h4
where h1.role_id=h2.role_id and h1.user_id=h3.id and h3.is_delete=0 and h3.crm_id=h4.user_id
and (h2.role_id=33201 or h2.role_id=33202) and h4.store_id in
( '2-Y4SQK3Q','2-S1PFC0Q','1-3EEO-49','2-THDMQDB','2-SQZX9SV','1-4ZHR-1'
,'2-QB9FJ5B','2-SQZX9TK','2-TBPMKV5','2-VHQMQL3','2-B3YY5WK','2-QZIO8PH','2-TNBXU19','2-W1JL0VS' );
group by最后排序