我需要统计手机号下有多少管辖的省和医院。但是省在视图中。医院在另外两个关联表中。 所以不能一次查询出省和医院的总计。但是加入union之后 运行时间太长,报表根本打不开。所以请教下各位大佬 有没有什么好的办法。下面是我的sql select sum(amount)/10000 as amount,sum(people) as people,sum(part) as part,date_format(createtime, '%Y/%m') as createtime from rims_reporting_image_review where PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( createtime, '%Y%m' ) ) <=11 and audit_status = 1 and agent_fk in ( select agent_uuid from view_permission_agent where username = '" + username + "' and agent_state = '1' and agent_parent_erp is null group by agent_uuid union select g.uuid from rims_basic_user u INNER JOIN rims_basic_area_user a on a.user_fk = u.uuid INNER JOIN rims_basic_logic_area l on a.area_fk = l.uuid INNER JOIN rims_basic_agent g on g.uuid = l.agent_fk where u.mobile = '"+username+"' and g.state = '1' and g.parent_project_erp is null ) group by date_format(createtime,'%Y%m') |