Q&A for people looking to bypass life's everyday problems with simple tricks
select id, parentid, row_number() OVER (partition by parentid order by id desc) from posts where parentid is not null