1 Answer
- Newest
- Most votes
- Most comments
1
I was able to achieve the results you expected with a different SQL. Kindly see if this will help your use case.
create table tst_ordr
( ID NUMERIC,
tmstmp TIMESTAMP
);
INSERT INTO tst_ordr values
(1001,'2023-10-01 08:00:00'),
(1002,'2023-10-01 08:00:00'),
(1002,'2023-10-01 08:30:00'),
(1002,'2023-10-01 09:00:00'),
(1003,'2023-10-01 08:00:00'),
(1003,'2023-10-01 08:15:00'),
(1003,'2023-10-01 08:30:00'),
(1003,'2023-10-01 08:45:00'),
(1004,'2023-10-01 08:30:00')
;
select *,
row_number()
over (partition by id
order by ID, tmstmp)
as "Order"
from tst_ordr
order by 1,3;
Relevant content
- asked a year ago
- asked 8 months ago
- asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
Thank you!! This is exactly what I was looking for!