select distinct on (id) id, attribute
from like_this
order by id, random()
Hvis du kun har brug for attributkolonnen:
select distinct on (id) attribute
from like_this
order by id, random()
Bemærk, at du stadig skal bestille efter id
først, da det er en kolonne af distinct on
.
Hvis du kun vil have de distinkte attributter:
select distinct attribute
from (
select distinct on (id) attribute
from like_this
order by id, random()
) s