【问题标题】:SQL order and limit then order the limited resultsSQL order and limit then order the limited 结果
【发布时间】:2012-07-20 15:32:24
【问题描述】:

我想按 DESC 选择日期并限制为最后 3 个,然后我需要基本上翻转最后 3 个结果,以便它们按 ASC 排序

任何帮助将不胜感激我正在使用 postgresql

【问题讨论】:

    标签: sql postgresql


    【解决方案1】:
    SELECT *
    FROM
      ( SELECT column_list
        FROM tableX
        ORDER BY dates DESC
        LIMIT 3
      ) AS tmp
    ORDER BY dates ASC ;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-20
      相关资源
      最近更新 更多