【发布时间】:2017-05-09 19:05:42
【问题描述】:
我正在使用 Trac 开发一个系统,我想限制返回的“更改日志”条目的数量。问题在于,Trac 使用union 从多个表中整理这些条目,然后根据它们的时间戳将它们组合成单个“变更集”。我希望将结果限制为最新的,例如3 个变更集,但这需要检索尽可能多的行,直到我获得 3 个唯一时间戳。解决方案需要适用于 SQLite/Postgres。
当前 SQL 结果
Time User Field oldvalue newvalue permanent
=======================================================================
1371806593507544 a owner b c 1
1371806593507544 a comment 2 lipsum 1
1371806593507544 a description foo bar 1
1371806593324529 b comment hello world 1
1371806593125677 c priority minor major 1
1371806592492812 d comment x y 1
预期的 SQL 结果(例如限制为 1 个时间戳)
Time User Field oldvalue newvalue permanent
=======================================================================
1371806593507544 a owner b c 1
1371806593507544 a comment 2 lipsum 1
1371806593507544 a description foo bar 1
【问题讨论】: