Friday 15 January 2010

sql - Select random x of top y records -


I have to pick 5 records randomly in the top 100 records ordered by the amount.

This can be divided into 2 questions but I do not know how to combine them with no function (which I am thinking can be less efficient). Question 1: P>

Question 2: SELECT TOP 5 * FROM (Query1) order by NEWID ()

I'm not sure how to combine them, even if they Use an internal joining or just an internal selection?

My first reaction was to try, which does not work:

  SELECT TOP 5 * (select the maximum number of cars based on prices) ORDER BY You must provide your subquery name:  
  
Choose from Top 5 * (select max 100 * of cars in order from value number) [A] Order by Nude ()

No comments:

Post a Comment