두 개의 groupby 쿼리가 있으며 각 각 compnay_id에 대한 행 수는 모두 company_id로 그룹화됩니다. 나는 SQL의 전문가가 아니에요하지만 당신을 위해 작업을 가입 LEFT 것모든 쿼리의 열을 하나의 열로 인쇄합니다.
select count(*) as qty1
from T_MISSION
where datepart(month, [mdatetime])=12
group by company_id
union all
select count(*) as qty2
from T_CUSTSK
where datepart(month, [sdate])=12
group by company_id
왜 sum() 함수를 사용 했습니까? – Alexxx
답변에 대한 설명을 참조하십시오. Sum() 실제로 행을 결합하는 트릭입니다. – RuDevel