Here is query:
ActiveRecord::StatementInvalid (PGError: ERROR: syntax error at or near “over”
select *, rank() over (partition by thread_i…
^
SELECT *
FROM (
select *, rank() over (partition by thread_id order by created_at DESC)
from posts
where circle_id IN (134) OR (receiver_id=3)
) as dt
WHERE rank = 1
EDIT: here is a detailed explanation of what I am trying to do:
Rails 3 app with PostgreSQL – Getting the list of messages grouped by converstation
It turns out the Heroku shared DB is a PostgreSQL version 8.3 therefore no windows function so the question become how can I do this query in PostgreSql 8.3?
THANKS!
try
EDIT – as per comment: