locked
Select Random Record From Database Table RRS feed

  • Question

  • User150370776 posted

    I need to select a random record from my database table, how can I do this? My query currently is:

    SELECT        FN, LN, Rate
    FROM Data
    ORDER BY Rate DESC
    Tuesday, August 9, 2011 2:10 PM

Answers

  • User150370776 posted

    I toyed with the query for a while and I finally fixed it, I had to remove "Rate," from it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 9, 2011 4:20 PM

All replies

  • User-1508232475 posted
    Hi, 
    please check this  query 
    SELECT TOP 1 FN,LN,Rate FROM DATA ORDER BY Rate,NewID() desc 
     
    thanks,
     
     
    Tuesday, August 9, 2011 2:21 PM
  • User150370776 posted

    It selected the first record, when I tried to rerun the query it didn't change

    Tuesday, August 9, 2011 2:24 PM
  • User150370776 posted

    I toyed with the query for a while and I finally fixed it, I had to remove "Rate," from it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 9, 2011 4:20 PM
  • User-1199946673 posted

    This question is posted in the Access Databases and AccessDataSource Control forum. But if this works, it means that you're using SQL Server, not Access, so this post should be moved...

    Wednesday, August 10, 2011 6:00 AM