Found a trick today for SQL from this site. I needed to get a random sample from a dataset, where each record has a unique ID record.
According to the site, the query to get one random record by its ID is:
"SELECT TOP 1 someColumn
FROM someTable
ORDER BY NEWID() "
If you change Top 1 to Top 50, you can get 50 random records according to their ID (someColumn in this case). Of course you can use any number you wish.
skip to main |
skip to sidebar
Tuesday, May 5, 2009
Subscribe to:
Post Comments (Atom)
Kate...
Archive
Labels
- #picmecomp (1)
- books (21)
- career (18)
- computer geekdom (40)
- conferences (39)
- datamining (8)
- frisbee (3)
- games (5)
- ghc08 (5)
- ghc10 (3)
- ghc11 (15)
- ghc12 (13)
- ghc13 (9)
- graduate school (23)
- iPhone (5)
- languages (1)
- LaTeX (3)
- life on a mountain (19)
- linux (3)
- movies (1)
- music (5)
- photography (6)
- programming (19)
- radio (4)
- robotics (21)
- scholarships (10)
- science fiction (33)
- science news (19)
- travel (54)
- windows phone (4)
- Women in Computing Science (65)
No comments:
Post a Comment