Results differ between query applied on single and query applied on whole branch accounts

Database
Enthusiast

Results differ between query applied on single and query applied on whole branch accounts

Dear All,

Please refer this

ACCOUNT_NUM = 680213

BRANCH_PARTY_ID = 12311

Both ACCOUNT_NUM and BRANCH_PARTY_ID are part of EVENT table.

Account No 680213 is part of branch 12311

I run following query on single account [mentioned above i.e. 680213] and it gives me 209 records of Account # 680213. Here is the query

WITH T1(ACCOUNT_NUM, DEBIT_CREDIT_CD, TOT_TO, TOT_TR) AS
(
SELECT ACCOUNT_NUM, DEBIT_CREDIT_CD, SUM(ABS(EVENT_AMT)) AS TOT_TO, COUNT(EVENT_AMT) AS TOT_TR
FROM DP_VIEW_T24_IBG.EVENT
WHERE ACCOUNT_NUM = '680213' AND EVENT_START_DT >= '2015-08-01' AND EVENT_START_DT <= '2016-07-31' AND EVENT_ACTIVITY_TYPE_CD NOT IN ('F-TC-ACC','F-TC-CAP','F-TC-CUS')
GROUP BY ACCOUNT_NUM, DEBIT_CREDIT_CD
)
SELECT T2.ACCOUNT_NUM AS ACCOUNT_NUMBER,
SUBSTRING(T2.Primary_Assoc_Party_Id FROM 6 FOR 8) AS CUSTOMER_NUMBER,
T2.AGREEMENT_NAME AS ACCOUNT_TITLE,
T2.PRODUCT_ID,
T1.DEBIT_CREDIT_CD,
T1.TOT_TO,
T1.TOT_TR
FROM DP_TAB.AGREEMENT AS T2
INNER JOIN T1 ON T1.ACCOUNT_NUM = T2.ACCOUNT_NUM
WHERE T2.BRANCH_PARTY_ID = '12311' AND SUBSTRING(T2.ACCOUNT_NUM FROM 1 FOR 1) = '5'
ORDER BY 1

How ever when i change the query opotion from account number to branch code and appy the query on branch 12311 for the same period it gives me only 100 records. refer the query

WITH T1(ACCOUNT_NUM, DEBIT_CREDIT_CD, TOT_TO, TOT_TR) AS
(
SELECT ACCOUNT_NUM, DEBIT_CREDIT_CD, SUM(ABS(EVENT_AMT)) AS TOT_TO, COUNT(EVENT_AMT) AS TOT_TR
FROM DP_VIEW_T24_IBG.EVENT
WHERE BRANCH_PARTY_ID = '12311' AND EVENT_START_DT >= '2015-08-01' AND EVENT_START_DT <= '2016-07-31' AND EVENT_ACTIVITY_TYPE_CD NOT IN ('F-TC-ACC','F-TC-CAP','F-TC-CUS')
GROUP BY ACCOUNT_NUM, DEBIT_CREDIT_CD
)
SELECT T2.ACCOUNT_NUM AS ACCOUNT_NUMBER,
SUBSTRING(T2.Primary_Assoc_Party_Id FROM 6 FOR 8) AS CUSTOMER_NUMBER,
T2.AGREEMENT_NAME AS ACCOUNT_TITLE,
T2.PRODUCT_ID,
T1.DEBIT_CREDIT_CD,
T1.TOT_TO,
T1.TOT_TR
FROM DP_TAB.AGREEMENT AS T2
INNER JOIN T1 ON T1.ACCOUNT_NUM = T2.ACCOUNT_NUM
WHERE T2.BRANCH_PARTY_ID = '12311' AND SUBSTRING(T2.ACCOUNT_NUM FROM 1 FOR 1) = '5'
ORDER BY 1

What could be the problem.

Regards

KAM