Kudret, I haven't used MSSQL, but there are two approaches I can think of. You'll need to check whether they are supported.
1) If the database supports random number generation, do an "order by" on that function and then use ROWNUM to return the first 20 rows. 2) Generate 20 random #s in Java between 1 and 600. Then add a clause to the WHERE to only return ROWNUMs matching those.