-- Getting a subsample of the data.
-- Uses the integer short object id (obj) and the '%' syntax (like awk) 
-- to get every 1000th object. THIS IS NOT A TRULY RANDOM SUBSET!
-- 
-- Returns 11367 objects in DR2 (in about 10-15mins).

SELECT u, g, r, i, z 
FROM Galaxy with (nolock)
WHERE (objID%1000) = 1 
   AND (r between 18 and 21)

