我写了一个查询,它连接了两个显示总数no. of appointments
并leads
使用union
关键字的表,我希望这个查询的结果显示在两个不同的列中,我有一个艰难的描述
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