There is a table name Top_Up. Its current snapshot is:
When I run query SELECT * FROM Top_Up WHERE Top_up_ID = (round(random() * 9 ) + 1); on it, I am getting random result. Sometimes it is returning with two tuples, sometimes no tuples and sometime one tuple.
To debug I run the query Select (round(random() * 9 ) + 1); and it is always returning only one tuple in the result.
Why I am getting this vague and random result?
Round is being calculated per row. Try this:
If you run your test against your table you should see a much different result:
If you just want a random record I would go with: