次の TSQL クエリを作成し、Microsoft Report Builder 内で実行しています。私の問題は、一部が正しく機能していないことです。どの情報も非常に役立ちます。ありがとう。
- 注 - (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) は、クエリが実行されている日付を返します。弊社標準機能の一つです。
これは私が問題を抱えている部分です。なんらかの理由で、NULL の締め日を持つローンが見つかりません。たとえば、私がテストしているアカウントには未処理のローンがありますが、返される値は 0 ですが、1 を受け取る必要があります。
(SELECT COUNT(*) -- Check if there are no open loans
FROM arcu.vwARCULoan AS L
WHERE A.ACCOUNTNUMBER=L.AccountNumber AND
L.ProcessDate = (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) AND
L.LoanCloseDate IS NOT NULL)=0 AND -- END Check if there are no open loans
以下はクエリ全体です。
SELECT
A.ACCOUNTNUMBER AS 'Account Number'
,A.AccountBranch AS 'Branch Number'
,A.AccountOpenDate AS 'Account Open Date'
,A.AccountActivityDate AS 'Last Activity Date'
,N.NameFirst+' '+N.NameLast AS 'Member Name'
FROM
arcu.vwARCUAccount AS A
LEFT OUTER JOIN arcu.vwARCUName AS N
ON A.ACCOUNTNUMBER = N.AccountNumber
WHERE
A.ProcessDate = (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) AND
A.AccountCloseDate IS NULL AND
A.AccountOpenDate>DATEADD(DAY,-30,A.AccountOpenDate) AND
N.NameType=0 AND
N.ProcessDate = (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) AND
(SELECT SUM(S.ShareBalance) -- Check if all shares are zero
FROM arcu.vwARCUShare AS S
WHERE A.ACCOUNTNUMBER=S.AccountNumber AND
S.ProcessDate = (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) AND
A.ProcessDate = (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()))=0 AND -- END Check if all shares are zero
(SELECT COUNT(*) -- Check if there are no open loans
FROM arcu.vwARCULoan AS L
WHERE A.ACCOUNTNUMBER=L.AccountNumber AND
L.ProcessDate = (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) AND
A.ProcessDate = (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) AND
L.LoanCloseDate IS NOT NULL)=0 AND -- END Check if there are no open loans
(SELECT COUNT(*) --Check if tracking records exist
FROM arcu.vwARCULoanTracking AS T
WHERE A.ACCOUNTNUMBER=T.AccountNumber AND
T.ProcessDate = (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) AND
A.ProcessDate = (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) AND
T.LoanTrackingType IN(@TRACKINGTYPES) )=0 AND --END Check if tracking records exist
(SELECT COUNT(*)
FROM arcu.vwARCUInventory AS I
WHERE A.ACCOUNTNUMBER=I.InventoryAccountNumber AND
I.ProcessDate = (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) AND
A.ProcessDate = (SELECT ProcessDate FROM ufnARCUGetLatestProcessDate()) AND
I.InventoryStatus=2 AND
I.InventoryType IN (@INVENTORYTYPE))=0
ORDER BY A.ACCOUNTNUMBER