David Fetter <david@xxxxxxxxxx> writes: > I tried this: > SELECT > typ, > ts, > rank() over w AS foo_rank > FROM > foo > WINDOW w AS (partition by typ order by ts desc) > WHERE > foo_rank < 4; > ERROR: syntax error at or near "WHERE" > LINE 8: WHERE > ^ RTFM ... WINDOW goes after WHERE (and GROUP BY, HAVING, ...) Also, we have never allowed SELECT-alias references in WHERE; window functions have nothing to do with that. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general