DECLARE
@start AS date = '2016-09-01 00:00:00',
@end AS date = '2016-09-01 23:59:00'
SELECT
CAST( je.RefDate AS date ) RefDate,
ChartOfAccounts.AcctName,
LEFT( ChartOfAccounts.FormatCode , 5 ) + '-+substring(ChartOfAccounts.FormatCode,6,2)+'-'+right(ChartOfAccounts.FormatCode,3) GLFormatCode,
txn.linememo,
txn.Debit - txn.Credit AS DebitCredit
FROM
Yapstone..JDT1 txn with (nolock)
INNER JOIN Yapstone..OJDT JE with (nolock) ON JE.transid = txn.TransId
INNER JOIN Yapstone..OACT ChartOfAccounts with (nolock) ON ChartOfAccounts.AcctCode = txn.Account
LEFT JOIN Yapstone..orct Incoming with (nolock) ON txn.TransId = Incoming.TransId
LEFT JOIN Yapstone..ovpm Outgoing with (nolock) ON txn.TransId = Outgoing.TransId
WHERE
JE.RefDate BETWEEN @start AND DATEADD( s, -1, DATEADD( d, 1, CAST(@end AS datetime ) ) )
AND
ChartOfAccounts.Segment_0 = 11600
查询结果:
2016-09-01 Prepaid Expense (Yap, Yap) 11600-01-000 A/P Invoices - VLinkedIn 20258.750000
2016-09-01 Prepaid Expense (Yap, Yap) 11600-01-000 To correct: Appriver Sept invoice was booked in Au -11084.250000
帮助:如何添加从一开始就开始的运行总计,以查看每项交易的影响?