【发布时间】:2019-03-07 22:35:59
【问题描述】:
我正在尝试按类型为 bigint 的列对分区上的数据进行排名,但是当我将分区中的列更改为带有时区的时间戳类型的列时,它不起作用。
我的查询如下所示:
select id,ts_insert,serial_no,rank() over (partition by serial_no order by serial_no desc) from schema.table_name
结果如下:
1,'2019-02-19 18:27:50.258846+11',19516,1
1,'2019-02-19 18:27:50.258846+11',19515,1
1,'2019-02-19 18:27:50.258846+11',19514,1
1,'2019-02-06 19:45:38.896062+11',15069,1
1,'2019-02-05 21:46:28.633325+11',14827,1
预期结果是:
1,'2019-02-19 18:27:50.258846+11',19516,1
1,'2019-02-19 18:27:50.258846+11',19515,2
1,'2019-02-19 18:27:50.258846+11',19514,3
1,'2019-02-06 19:45:38.896062+11',15069,4
1,'2019-02-05 21:46:28.633325+11',14827,5
有人可以帮帮我吗?
提前谢谢...
【问题讨论】:
标签: sql postgresql window-functions