带有时间戳的postgreSQL排序 [英] postgreSQL sorting with timestamps

查看:1005
本文介绍了带有时间戳的postgreSQL排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下SQL语句:

SELECT * FROM schema."table"
  WHERE "TimeStamp"::timestamp >= '2016-03-09 03:00:05'
  ORDER BY "TimeStamp"::date asc
  LIMIT 15

我期望它做什么?按升序给出表的15行,其中时间戳相同且大于该日期。但是postgres以错误的顺序发送行。第一项位于最后一个位置。
那么,有谁知道结果为什么如此奇怪?

What do I expect it to do? Giving out 15 rows of the table, where the timestamp is the same and bigger than that date, in ascending order. But postgres sends the rows in the wrong order. The first item is on the last position. So has anyone an idea why the result is this strange?

推荐答案

只需使用 ORDER BY TimeStamp (迄今为止尚未进行强制转换)即可。

Use simply ORDER BY "TimeStamp" (without casting to date).

这篇关于带有时间戳的postgreSQL排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆