Jonna jo

Jonna jo

  • NA
  • 33
  • 29.9k

sql query to select questions randomly each time

Mar 28 2013 1:22 AM
Dear All,
I am using this following query to select questions randomly from database 

    
sql query:

("select top 5 * from "+ practicallab +" where subtopic ='"+ sub_topic +"' order by newid()")

The above query is working to select questions randomly from database.

But my problem is,

If i want to select five questions randomly from twenty questions i can select using the above query.

(1,2,3,4,5,6,7........20)questions are there.

when i run the program like 5,9,15,18,20 question are displayed.

Again when i run the program 6,4,13,18,15 questions are displayed.

But when i run again and again one or two same questions are repeatedly displayed.

I want to display different five questions(randomly) each time.

 what is the sql query for this process?

Answers (1)