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 |
|
csphard
Posting Yak Master
113 Posts |
Posted - 2005-08-24 : 12:23:34
|
| I am selecting the top 200 while order by newid() to get a random sample and it works. I can see that it is random because I do not get the same numbers every time. My quesetion is does the statement get the random data first and then gives me the top 200. Or am I getting the 200 and randomizing it. Since the numbers are not the same I feel it is using my criteria and then giving me the top 200 of thatsqlselect top 200 e.lname,e.fname,e.empid,e.item,e.pay_location,e.sub,e.bureau,e.division,d.eval_typefrom emp_information e,due_evals d,new_organization o,new_organization nWHERE e.deptno <> '999' and e.empid = d.empid and datepart(yyyy,d.todate) = '2005'and e.empid LIKE '_[678]%'order by NEWID() |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-08-24 : 12:34:27
|
order by first then top.look at the execution plan of the query.Go with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|