SQL

SQL

Thursday, April 4, 2013

Statistical Sampling in SQL


 It’s been awhile since I have blogged, I have been extremely busy working with a few other SQL Server enthusiast working on the next great application, but that’s for another time. Today I want to share with you a simple way to pull a statistical sample using SQL. Using the code below, you can pull a quick sample


Select TOP 10  - The number of samples you want to pull back of your criteria


From – The Table your information is coming from

Order By NEWID() – I don’t want to cause any confusion by going into this function, just know that you need it. If you want to know more, start at this site below http://sqlmag.com/sql-server/change-behavior-rand-and-newid-sql-server-2005


Good luck

Curt