My requirement is to get distinct records and in order
User.joins('INNER JOIN report_posts ON posts.id = report_posts.post_id').select('DISTINCT ON (report_posts.post_id) posts.id as report_posts.id as reported_id, report_posts.reported_at').order('report_posts.reported_at desc')
I know this is not possible in postgresql
, I already read this Postgresql DISTINCT ON with different ORDER BY
I want its solution that how can I do do this, its alternate way?