Hi,

I'm trying to find a way to select a random row from a group (rather
than "arbitrary"). Something like:

SELECT attr1, attr2
FROM foo
GROUP BY attr1
ORDER BY attr1, random()

but of course ORDER BY is done after GROUP BY has selected an
arbitrary row. Looking online, I've seen non-standard solutions which
aren't supported in sqlite. For example:

select distinct on (id) id, attribute
from like_this
order by id, random()

from 
http://stackoverflow.com/questions/16044828/select-random-row-for-each-group

Any pointers would be appreciated!

-- 
Patrick Donnelly
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to