SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table if not exists transactions ( transaction_id int, merchant_id int, credit_card_id INT, amount int, transaction_timestamp timestamp ); insert into transactions values (1,101,1,100,'2022-09-25 12:00:00'), (2,101,1,100,'2022-09-25 12:08:00'),(3,101,1,100,'2022-09-25 12:28:00'), (4,102,2,300,'2022-09-25 12:00:00'),(6,102,2,400,'2022-09-25 14:00:00'); select * from transactions; with cte as( select merchant_id, extract(epoch from transaction_timestamp - lag(transaction_timestamp) over(partition by merchant_id, credit_card_id, amount order by transaction_timestamp))/60 as minute_diff from transactions) select count(merchant_id) as payment_count from cte where minute_diff<-10;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear