You are on page 1of 2

(

SELECT
t1.gatewayTransactionId AS aftGatewayTransactionId,
t1.transactionId AS aftTransactionId,
t1.tid AS aftTid,
t1.transactionTypeCode AS aftTransactionTypeCode,
t1.captureDate AS aftCaptureDate,
CONVERT(t1.isProcessByOrphanBatch, CHAR) AS aftIsProcessByOrphanBatch,
CONVERT(IF(ISNULL(t1.isOrphan), NULL, ISNULL(t2.isOrphan)), CHAR) AS
aftIsOrphan,
t2.gatewaytransactionId AS octGatewaytransactionId,
t2.transactionId AS octTransactionId,
t2.tid AS octTid,
t2.transactionTypeCode AS octTransactionTypeCode,
t2.captureDate AS octCaptureDate,
CONVERT(t2.isProcessByOrphanBatch, CHAR) AS octIsProcessByOrphanBatch,
CONVERT(IF(ISNULL(t2.isOrphan), NULL, ISNULL(t1.isOrphan)), CHAR) AS
octIsOrphan
FROM
`sirius-trx`.gatewayTransactions t1
LEFT JOIN (
SELECT
gatewaytransactionId,
transactionId,
transactionTypeCode,
tid,
isOrphan,
isProcessByOrphanBatch,
captureDate
FROM
`sirius-trx`.gatewayTransactions
WHERE
brandCode = 'VI'
AND serviceId = 1
AND businessApplicationIdentifier = 'PP'
AND authorizerCode = 'VD'
AND transactionTypeCode = 'OCT' -- AND isOrphan = 1
AND isProcessByOrphanBatch = 0
) t2 ON t1.tid = t2.tid
WHERE
brandCode = 'VI'
AND t1.serviceId = 1
AND t1.businessApplicationIdentifier = 'PP'
AND t1.authorizerCode = 'VD'
AND t1.transactionTypeCode = 'AFT' -- AND t1.isOrphan = 1
AND t1.isProcessByOrphanBatch = 0
AND TIMESTAMPDIFF(MINUTE, t1.captureDate, CONVERT('2023-02-13 01:15:00',
DATETIME)) > 10
)
UNION
(
SELECT
t2.gatewayTransactionId AS aftGatewayTransactionId,
t2.transactionId AS aftTransactionId,
t2.tid AS aftTid,
t2.transactionTypeCode AS aftTransactionTypeCode,
t2.captureDate AS aftCaptureDate,
t2.isProcessByOrphanBatch AS aftIsProcessByOrphanBatch,
CONVERT(IF(ISNULL(t2.isOrphan), NULL, ISNULL(t1.isOrphan)), CHAR) AS
aftIsOrphan,
t1.gatewaytransactionId AS octGatewaytransactionId,
t1.transactionId AS octTransactionId,
t1.tid AS octTid,
t1.transactionTypeCode AS octTransactionTypeCode,
t1.captureDate AS octCaptureDate,
CONVERT(t1.isProcessByOrphanBatch, CHAR) AS octIsProcessByOrphanBatch,
CONVERT(IF(ISNULL(t1.isOrphan), NULL, ISNULL(t2.isOrphan)), CHAR) AS
octIsOrphan
FROM
`sirius-trx`.gatewayTransactions t1
LEFT JOIN (
SELECT
gatewayTransactionId,
transactionId,
transactionTypeCode,
tid,
isOrphan,
isProcessByOrphanBatch,
captureDate
FROM
`sirius-trx`.gatewayTransactions
WHERE
brandCode = 'VI'
AND serviceId = 1
AND businessApplicationIdentifier = 'PP'
AND authorizerCode = 'VD'
AND transactionTypeCode = 'AFT' -- AND isOrphan = 1
AND isProcessByOrphanBatch = 0
) t2 ON t1.tid = t2.tid
WHERE
brandCode = 'VI'
AND t1.serviceId = 1
AND t1.businessApplicationIdentifier = 'PP'
AND t1.authorizerCode = 'VD'
AND t1.transactionTypeCode = 'OCT' -- AND t1.isOrphan = 1
AND t1.isProcessByOrphanBatch = 0
AND TIMESTAMPDIFF(MINUTE, t1.captureDate, CONVERT('2023-02-13 01:15:00',
DATETIME)) > 10
);

You might also like