3

Exact Online的mailmessagesreceivedmailmessagessent包含客户所有部门的所有工作。为了在我们的 SQL Server 数据库中检索它们,我们使用以下查询:

use select min(code) from systemdivisions group by customercode

通过使用,min我们确保每个客户代码的部门代码随时间保持不变。

然后加载数据:

select /*+ ods(true, interval '20 hours') */ * from mailmessagessent

select /*+ ods(true, interval '20 hours') */ * from mailmessagesreceived

但是,该字段ForDivision通常为空。它仅用于银行对账单,例如 MT940。

对于在 Exact Online 上拥有自己订阅的公司来说,这不是问题。然后min(code)是他们自己的划分。

但是我们需要为我们的会计订阅下的所有部门评估每个部门要完成的工作量。

我们如何将 themailmessagesreceived和 themailmessagessent与他们的 Exact Online 部门联系起来?

4

1 回答 1

3

这是一个“功能”或“错误”,具体取决于您如何看待 ForDivision for MailmessagesSentreceived中的缺失值。

通过以下查询,我确定了每个帐户发送和接收的打开邮件列表:

use select min(code) from systemdivisions where status = 1 /* Active. */ group by customercode

select mbx.accountname
,      mbx.ForDivisionDescription 
,      mbx.ForDivision
,      mrd.*
from   MailMessagesReceived mrd
join   mailboxes mbx
on     mbx.id = mrd.recipientmailboxid
--and    mbx.ForDivision = 886678
where  mrd.recipientstatus in (10, 20, 25, 30) /* 10: Draft, 20: Open, 25: Prepared, 30: Approved */

您还可以按客户汇总报告它们:

select mbx.accountname
,      mbx.ForDivisionDescription 
,      mbx.ForDivision
,      count(*)
from   MailMessagesReceived mrd
join   mailboxes mbx
on     mbx.id = mrd.recipientmailboxid
where  mrd.recipientstatus in (10, 20, 25, 30) /* 10: Draft, 20: Open, 25: Prepared, 30: Approved */
group
by     mbx.accountname
,      mbx.ForDivisionDescription 
,      mbx.ForDivision

诀窍是邮箱中的 ForDivision与 Exact Online 的 MailMessagesSent/Received 具有不同的语义。

2018 版本提供了简化版本:

select mrd.RecipientMailboxCustomerName
,      mrd.RecipientMailboxForDivisionDescription
,      mrd.RecipientMailboxForDivision
,      count(*)
from   MailMessagesReceived mrd
where  mrd.recipientstatus in (10, 20, 25, 30) /* 10: Draft, 20: Open, 25: Prepared, 30: Approved */
and    mrd.division in ( select /*+ low_cost */ min(sdn.code) from systemdivisions sdn group by sdn.customer )
group
by     mrd.RecipientMailboxCustomerName
,      mrd.RecipientMailboxForDivisionDescription
,      mrd.RecipientMailboxForDivision

或简称:

select mrd.RecipientMailboxCustomerName
,      mrd.RecipientMailboxForDivisionDescription
,      mrd.RecipientMailboxForDivision
,      count(*)
from   MailMessagesReceivedUnhandled mrd
group
by     mrd.RecipientMailboxCustomerName
,      mrd.RecipientMailboxForDivisionDescription
,      mrd.RecipientMailboxForDivision
于 2017-12-29T09:49:17.050 回答