ancheswaroop
Programmer
Table 1: TRAN_ADJUSTMENT_REC
Table 2: DLY_TRAN_FILE
I am matching this two tables with this Query
select count(1)
from
TEDCLZ.TRAN_ADJUSTMENT_REC
INNER JOIN
TEDCLZ.DLY_TRAN_FILE
on
cast((REPLACE(substr(cast(date(cast(substr(TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_DATE,5,3) as int))as char(10)),6,5)||''||
substr(TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_DATE,1,4),'-','')) as char(10)) = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_DATE
AND cast((REPLACE(substr(cast(date(cast(substr(TEDCLZ.DLY_TRAN_FILE.AT31_DATE_POSTED,5,3) as int))as char(10)),6,5)||''||
substr(TEDCLZ.DLY_TRAN_FILE.AT31_DATE_POSTED,1,4),'-','')) as char(10)) = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE
AND substr(TEDCLZ.DLY_TRAN_FILE.AT31_AMT_TRANSACTION,2,14) = substr(TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_AMOUNT,4,14)
AND TEDCLZ.DLY_TRAN_FILE.AT31_REFERENCE_NUMBER = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_REF_NUM
AND TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_CODE = TEDCLZ.TRAN_ADJUSTMENT_REC.TRAN_CODE
AND TEDCLZ.DLY_TRAN_FILE.HASH_SRC_CRCD_I = TEDCLZ.TRAN_ADJUSTMENT_REC.HASH_SRC_CRCD_I
WHERE TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE='01112006'
No. of records in TRAN_ADJUSTMENT_REC( Table 1) is 13179
No. of records match are 13036
143 records are not matching
Now i want that 143 records from table 1 which are not matching to table 2
When i am using this query i am not getting any records ( query is running no error message)
select
TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_DATE,
TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE,
TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE,
TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_REF_NUM,
TEDCLZ.TRAN_ADJUSTMENT_REC.TRAN_CODE,
TEDCLZ.TRAN_ADJUSTMENT_REC.TCAT_CODE,
TEDCLZ.TRAN_ADJUSTMENT_REC.HASH_SRC_CRCD_I
from
TEDCLZ.TRAN_ADJUSTMENT_REC
left outer join
TEDCLZ.DLY_TRAN_FILE
on
cast((REPLACE(substr(cast(date(cast(substr(TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_DATE,5,3) as int))as char(10)),6,5)||''||
substr(TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_DATE,1,4),'-','')) as char(10)) = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_DATE
AND cast((REPLACE(substr(cast(date(cast(substr(TEDCLZ.DLY_TRAN_FILE.AT31_DATE_POSTED,5,3) as int))as char(10)),6,5)||''||
substr(TEDCLZ.DLY_TRAN_FILE.AT31_DATE_POSTED,1,4),'-','')) as char(10)) = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE
AND substr(TEDCLZ.DLY_TRAN_FILE.AT31_AMT_TRANSACTION,2,14) = substr(TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_AMOUNT,4,14)
AND TEDCLZ.DLY_TRAN_FILE.AT31_REFERENCE_NUMBER = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_REF_NUM
AND TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_CODE = TEDCLZ.TRAN_ADJUSTMENT_REC.TRAN_CODE
AND TEDCLZ.DLY_TRAN_FILE.HASH_SRC_CRCD_I = TEDCLZ.TRAN_ADJUSTMENT_REC.HASH_SRC_CRCD_I
WHERE TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE='01112006'
AND TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_AMOUNT IS NULL
is this query is correct.(left outer join)
Table 2: DLY_TRAN_FILE
I am matching this two tables with this Query
select count(1)
from
TEDCLZ.TRAN_ADJUSTMENT_REC
INNER JOIN
TEDCLZ.DLY_TRAN_FILE
on
cast((REPLACE(substr(cast(date(cast(substr(TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_DATE,5,3) as int))as char(10)),6,5)||''||
substr(TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_DATE,1,4),'-','')) as char(10)) = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_DATE
AND cast((REPLACE(substr(cast(date(cast(substr(TEDCLZ.DLY_TRAN_FILE.AT31_DATE_POSTED,5,3) as int))as char(10)),6,5)||''||
substr(TEDCLZ.DLY_TRAN_FILE.AT31_DATE_POSTED,1,4),'-','')) as char(10)) = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE
AND substr(TEDCLZ.DLY_TRAN_FILE.AT31_AMT_TRANSACTION,2,14) = substr(TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_AMOUNT,4,14)
AND TEDCLZ.DLY_TRAN_FILE.AT31_REFERENCE_NUMBER = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_REF_NUM
AND TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_CODE = TEDCLZ.TRAN_ADJUSTMENT_REC.TRAN_CODE
AND TEDCLZ.DLY_TRAN_FILE.HASH_SRC_CRCD_I = TEDCLZ.TRAN_ADJUSTMENT_REC.HASH_SRC_CRCD_I
WHERE TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE='01112006'
No. of records in TRAN_ADJUSTMENT_REC( Table 1) is 13179
No. of records match are 13036
143 records are not matching
Now i want that 143 records from table 1 which are not matching to table 2
When i am using this query i am not getting any records ( query is running no error message)
select
TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_DATE,
TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE,
TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE,
TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_REF_NUM,
TEDCLZ.TRAN_ADJUSTMENT_REC.TRAN_CODE,
TEDCLZ.TRAN_ADJUSTMENT_REC.TCAT_CODE,
TEDCLZ.TRAN_ADJUSTMENT_REC.HASH_SRC_CRCD_I
from
TEDCLZ.TRAN_ADJUSTMENT_REC
left outer join
TEDCLZ.DLY_TRAN_FILE
on
cast((REPLACE(substr(cast(date(cast(substr(TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_DATE,5,3) as int))as char(10)),6,5)||''||
substr(TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_DATE,1,4),'-','')) as char(10)) = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_DATE
AND cast((REPLACE(substr(cast(date(cast(substr(TEDCLZ.DLY_TRAN_FILE.AT31_DATE_POSTED,5,3) as int))as char(10)),6,5)||''||
substr(TEDCLZ.DLY_TRAN_FILE.AT31_DATE_POSTED,1,4),'-','')) as char(10)) = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE
AND substr(TEDCLZ.DLY_TRAN_FILE.AT31_AMT_TRANSACTION,2,14) = substr(TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_AMOUNT,4,14)
AND TEDCLZ.DLY_TRAN_FILE.AT31_REFERENCE_NUMBER = TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_REF_NUM
AND TEDCLZ.DLY_TRAN_FILE.AT31_TRANSACTION_CODE = TEDCLZ.TRAN_ADJUSTMENT_REC.TRAN_CODE
AND TEDCLZ.DLY_TRAN_FILE.HASH_SRC_CRCD_I = TEDCLZ.TRAN_ADJUSTMENT_REC.HASH_SRC_CRCD_I
WHERE TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_POST_DATE='01112006'
AND TEDCLZ.TRAN_ADJUSTMENT_REC.TRANSACTION_AMOUNT IS NULL
is this query is correct.(left outer join)