【问题标题】:Where would the Limit statement go? Postgresql限制语句会去哪里? PostgreSQL
【发布时间】:2014-06-27 19:16:01
【问题描述】:

小问题,限制子句在 Postgresql 中的位置是什么? 我想将行数限制为 10,但这样做时会出错;

From this_table x
    join this_table y
    on x.no = y.no


where x.no = '7'
Limit 10
group by x.location
order by x.location

它在“where”处或附近给我一个语法错误

(如果需要,我可以添加 select 语句。

【问题讨论】:

标签: sql postgresql where sql-limit


【解决方案1】:

limitselect 查询中的最后一个子句,所以它在order by 之后:

select <whatever>
From this_table x
    join this_table y
    on x.no = y.no
where x.no = '7'
group by x.location
order by x.location
Limit 10;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-04
    • 2014-05-14
    • 2017-03-26
    • 1970-01-01
    • 1970-01-01
    • 2017-02-22
    相关资源
    最近更新 更多