2

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?

0

1 Answer 1

3

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.

1