I think you can achieve that by truncating your timestamp on the nearest multiple of 10 minutes: you could replace to_char(CREATED_TIMESTAMP) as timestamp
with regexp_replace(to_char(CREATED_TIMESTAMP, 'dd-Mon-yyyy hh24:mi'), '.$', '0')
and I think your group by would then be ok.
EDIT : the previous solution was only working if the 2 transactions were part of the same multiple of 10 minutes. Here is a better one:
Select *
From
(
Select CREATED_TIMESTAMP,
SOURCE_MSISDN||DEST_MSISDN||AMOUNT as trans,
lag(CREATED_TIMESTAMP, 1, null) over (partition by SOURCE_MSISDN||DEST_MSISDN||AMOUNT order by CREATED_TIMESTAMP) as PREVIOUS_TIMESTAMP
From ADMDBMC.TRANSACTION_CASH
Where TO_date(CREATED_TIMESTAMP) >= '1-sep-2014'
And TO_date(CREATED_TIMESTAMP) < '2-sep-2014'
And STATUS_DESCRIPTION='SUCCESS'
)
where CREATED_TIMESTAMP <= PREVIOUS_TIMESTAMP + INTERVAL '10' MINUTE
The lag
analytical function allows to get for every row the timestamp of preceeding row of the same group identified by the concatenation of SOURCE_MSISDN
/ DEST_MSISDN
/ AMOUNT
. Then once we have this, we just have to check the difference.