SQL Question with Random inputs(bug)