1 個回答
- 最新
- 最多得票
- 最多評論
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;
已回答 7 個月前
相關內容
- 已提問 1 年前
- AWS 官方已更新 5 個月前
Thank you!! This is exactly what I was looking for!