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