create table testtable04 (
id int, r_date timestamp, status text
);
insert into testtable04 (id, r_date, status)
values
(
1, '2023-01-18 05:35:15', 'registration5'
),
(
1, '2023-01-18 05:34:15', 'registration4'
),
(
1, '2023-01-18 05:33:15', 'registration3'
),
(
1, '2023-01-18 05:32:15', 'registration2'
),
(
1, '2023-01-18 05:31:15', 'registration1'
),
(
2, '2023-01-18 06:31:15', 'registration1'
),
(
2, '2023-01-18 06:38:05', 'registration2'
),
(
3, '2023-01-14 10:01:00', 'registration1'
),
(
4, '2023-01-18 06:38:05', 'registration1'
);
select
id,
max(r_date) - min(r_date) minute_difference
from
testtable04
group by
id;