-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.

Padagomez
  • 1,114
  • 5
  • 14
  • 35

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,242,037
  • 58
  • 646
  • 786