Quantcast
Channel: Postgresql - ORDER BY random() but also sort by id? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Postgresql - ORDER BY random() but also sort by id?

$
0
0

is it possible to order by random, and then order by an id?

In other words - can I tell to postgresql that it should return 10 random elements, but also give it out by sorting by the id column?

Right now it seems I can doORDER BY random()and that works, but I get a wild, unsorted result, so I now want to sort that result by the main id it uses, but I seem to be unable to apply to ORDER BY statements.

Normally I would sort by doing this:

ORDER BY id

But this does not work if I already order by random...


Viewing all articles
Browse latest Browse all 2

Trending Articles