Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | sparamesStarting Member
 
 
                                        5 Posts | 
                                            
                                            |  Posted - 2011-10-17 : 15:42:41 
 |  
                                            | Guys please help me explain this query in simple english. I need to write this for my research paper.SELECT TOP 3000 *FROM ExclusiveORDER BY Rnd(TimeValue(Now())*-10000000*[t1_ID1]); |  |  
                                    | TGMaster Smack Fu Yak Hacker
 
 
                                    6065 Posts | 
                                        
                                          |  Posted - 2011-10-17 : 16:56:09 
 |  
                                          | "TOP n" combined with "ORDER BY <random value>" has the effect of returning a random set of n rows.  Assuming your table has more then 3000 rows you should expect a different result set every time the query runs even if the table is static.Be One with the OptimizerTG |  
                                          |  |  |  
                                    | sparamesStarting Member
 
 
                                    5 Posts | 
                                        
                                          |  Posted - 2011-10-17 : 17:48:21 
 |  
                                          | Thanks a lot. Can you please throw more light on Rnd(TimeValue(Now())*-10000000*[t1_ID1]) |  
                                          |  |  |  
                                    | TGMaster Smack Fu Yak Hacker
 
 
                                    6065 Posts | 
                                        
                                          |  Posted - 2011-10-17 : 18:39:01 
 |  
                                          | that is the expression that generates a random number (which you are ordering by).  It is 3 functions nested inside one another.  The result of Now() is the argument to TimeValue().  That result is multiplied by the the product of -10000000 and the ID of that row - and that whole thing is used as the argument to the Rnd() function.  It is designed to generate a different value for every row of the table and be deliberately inconsistent such that the next time you run the query the same row will generate a completely different value from the last run.  What is your research paper about?Be One with the OptimizerTG |  
                                          |  |  |  
                                    | sparamesStarting Member
 
 
                                    5 Posts | 
                                        
                                          |  Posted - 2011-10-17 : 21:42:10 
 |  
                                          | My research paper is about analyzing a set of data for "Emergency Preparedness". I used this query from a forum to generate random records from my database in Access.. Now while writing the thesis a detailed description about the query is needed.  So, I needed the meaning of this query in a sentence. |  
                                          |  |  |  
                                |  |  |  |