Postgresql – Find N latest rows for each row in the main table
For each row in table line there can be many rows in table line_version. I need to find only N (let's say 2) "latest" rows for each line row. Latest here means the largest IDs. For example, that's how line_version…