我想针对与客户合同相关的每个案例运行我的报告。现在,我可以在帐户级别运行报告。我使用了如下过滤视图:
dbo.FilteredAccount AS CRMAF_FilteredAccount
on CRMAF_FilteredAccount.accountid = I.CustomerId
WHERE A.PartyObjectTypeCode = 8 AND A.PartyIdName IS NOT NULL
我希望能够针对与合同关联的帐户的每个案例运行相同的报告。我尝试使用 FilteredIncident 视图,但我不确定我做得对。
从评论中查询:
SELECT I.CustomerIdName AS 'Customer Name',
S.CreatedOn AS 'Task Start Date',
S.Subject AS 'Task Performed',
A.PartyIdName AS 'Resource',
S.Description,
cast((S.ActualDurationMinutes / 480) as varchar(5)) +' day(s)' + ', ' +
cast((S.ActualDurationMinutes% 480) / 60 as varchar(2))+' hour(s)'
as 'Time Spent',
S.ActualDurationMinutes AS 'Total Time',
S.ActualDurationMinutes AS 'Total'
FROM dbo.Incident I
JOIN [dbo].[ServiceAppointment] S ON I.IncidentId = S.RegardingObjectId
JOIN dbo.ActivityParty A ON S.ActivityId = A.ActivityId