PostgreSQL Seleccione Top 1 de cada grupo
SELECT rank_filter.* FROM (
SELECT items.*,
rank() OVER (
PARTITION BY color
ORDER BY created_at DESC
)
FROM items
WHERE items.cost < 50
) rank_filter WHERE RANK = 1
Zaur Tskhvaradze