早上好,是否可以从交叉表查询中计算 2 个计算列的百分比,我的缩减查询如下?
Select
a.ContactFullName As Adviser,
Sum(Month(b.CaseDate) = 1) As Jan,
Sum(Month(b.CaseDate) = 2) As Feb,
Sum(Month(b.CaseDate) = 3) As Mar,
Count(b.CaseID) As Total,
Count(b.StatusSubmittedDate) As Comms
From
tblcontacts a Inner Join
tblcases b On a.ContactID = b.ContactAssignedTo
Group By
a.ContactFullName With Rollup
这是将月份输出为显示每个月案例的列,Total 列计算行,而 Comms 列仅计算带有日期的案例。我想做的是计算 Total/Comms 的百分比;
Total | Comms | %_Share
100 | 50 | 50%
346 | 53 | 15%
278 | 89 | 32%
我看错了,我应该创建多个查询来实现吗?
感谢您的关注