我要看每个报表都有哪些用户有权限来看,根据finedb的er图进行关联,个人感觉没问题,但是查出来的数据跟从决策系统导出的excel数据不一致。决策系统导出的excel数据里面有一些离职人,所以我想根据finedb来查一下还在职的人with tmp_a as ( --权限表 取有查看权限并且目录权限 select t2.displayName,t1.roleId from fine_authority t1 left join fine_authority_object t2 on t1.AUTHORITYENTITYID = t2.id where t1.AUTHORITY = 2 ) ,tmp_b as ( -- 取用户姓名和用户Id select realName,t2.userId,t2.roleId from fine_user t1 left join fine_user_role_middle t2 on t1.id = t2.userId where t1.enable = 1 ) ,tmp_c as ( select t1.displayName , t2.realName from tmp_a t1 left join tmp_b t2 on t1.roleId = t2.roleId where t2.realName is not null) select t2.displayName ,(select realName+',' from tmp_c t1 where t1.displayName = t2.displayName for xml path('')) as name from tmp_c t2 group by t2.displayName |