我有 4 个子查询,每个子查询都按“组名”分组。尝试将每个子查询作为一个列,全部按“组名”分组。这是查询:
select
coalesce(co.group_name, requests.group_Name, incidents.group_Name, problems.group_Name) as 'SD Groups'
, isnull(co.co, '') as 'CO'
, isnull(incidents.incidents, '' ) as 'Inc'
, isnull(problems.problems, '') as 'Prob'
, isnull(requests.requests, '') as 'Rqst'
from
(
select
groups.last_name AS Group_Name
,count(chg_ref_num) AS 'CO'
from chg
left join ca_contact groups
on chg.group_id = groups.contact_uuid
left join ca_contact assignee
on chg.assignee = assignee.contact_uuid
left join ca_company cc
on assignee.company_uuid = cc.company_uuid
where
groups.last_name in ('8197 Qlikview Support', '8202 OBIEE-BIP'
, '8205 BI SAS', '8206 …
Run Code Online (Sandbox Code Playgroud)