Tags / greatest-n-per-group
SELECT DISTINCT ON (label) * FROM products ORDER BY label, created_at DESC;
Retrieving the Latest Records from a Table Using Row Numbers in SQL
Understanding Lateral Joins in PostgreSQL: A Deep Dive
Joining Two Tables and Getting the Most Recent Records for a Given Name: A SQL Solution Using Correlated Subqueries