2014-05-09 26 views
-2

簡短的問題,限制條款將在Postgresql中出現在哪裏? 我想將行數限制爲10,但是當我這樣做時它給了我一個錯誤;Limit語句將在哪裏出現? Postgresql

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 

它給我一個語法錯誤或接近「其中」

(如果需要,我可以添加SELECT語句。

+0

http://www.postgresql.org/docs/current/static/sql-select.html –

回答

2

limit處於select查詢的最後條款,所以它在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;