合計を表示する 2 つのテーブルを結合no. of appointments
し、キーワードをleads
使用するクエリを作成union
しました。このクエリの結果を 2 つの異なる列に表示したいのですが、難しい説明があります。
SELECT COUNT(FilteredAppointment.createdbyname) AS Appointment
FROM FilteredBusinessUnit
INNER JOIN FilteredSystemUser
ON FilteredBusinessUnit.businessunitid = FilteredSystemUser.businessunitid
INNER JOIN FilteredAppointment
ON FilteredSystemUser.systemuserid = FilteredAppointment.createdby
UNION
SELECT COUNT(FilteredLead.fullname) AS Lead
FROM FilteredBusinessUnit
INNER JOIN FilteredSystemUser
ON FilteredBusinessUnit.businessunitid = FilteredSystemUser.businessunitid
INNER JOIN FilteredLead
ON FilteredSystemUser.systemuserid = FilteredLead.createdby
WHERE (FilteredBusinessUnit.name IN (@Branch))
私の望ましい結果は次のとおりです。
CRITERIA | Appointment | Leads
Total | 200 | 123