-2

Short Question, where would the limit clause go in Postgresql? I want to limit the amount of rows to 10, but it is giving me an error when I do;

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

It's giving me a syntax error at or near "where"

(If requested, I could add the select statement.

a_horse_with_no_name
  • 440,273
  • 77
  • 685
  • 758
Padagomez
  • 844
  • 4
  • 11
  • 30

1 Answers1

2

limit is the last clause in a select query, so it goes after the 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;
Gordon Linoff
  • 1,122,135
  • 50
  • 484
  • 624