Limit声明会在哪里发生? PostgreSQL的

时间:2014-05-09 22:31:32

标签: sql postgresql where sql-limit

简短问题,限制条款将在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语句。

1 个答案:

答案 0 :(得分:2)

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;