PostgreSQL Wählen Sie die Top 1 aus jeder Gruppe aus
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