2

This question already has an answer here:

I have been working on getting the Id of a random non closed question and came up with this:

Select Id from posts where ClosedDate IS NULL ORDER BY RAND() 

For some reason I get the same results every time. Is this a bug or am I just doing this wrong?

marked as duplicate by Laurel, Nathan Tuggy, Glorfindel, ben is uǝq backwards, rene Mar 28 '17 at 7:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4

RAND is pretty useless in Data Explorer because it caches the results. If you run the same query on the same site with the same data, it will just load the results which were displayed last time because it's faster and "nothing changed" in the query that would suggest a different set of results would appear. This cache eventually expires after a little while (I'm not sure exactly how long they're cached).

Essentially, you can't really use RAND in our system. It will "work" in the sense that the query will run, but won't do much else for you.

Not the answer you're looking for? Browse other questions tagged .