-- Stars with colors like those of a quasar at high redshift 
-- Find all star-like objects within similar colors to a
-- quasar at 5.5 < redshift < 6.5.

SELECT 
    s.objID, s.iMag, s.grColor, s.riColor, s.izColor 
FROM Star s 			    -- for each star-like object
	-- for a full scan, remove the Cone Search constraint
	JOIN dbo.fGetNearbyObjEq(221.30, 1.5, 90) n -- search on 1.5 degree
		ON s.objID = n.objID  -- only stars
WHERE 
    ( iMag BETWEEN 0 AND 19 ) 
    AND ( grColor > 1.0 ) 
    AND ( (riColor < (0.08 + 0.42 * (grColor - 0.96))) OR (grColor > 2.26 ) ) 
    AND ( izColor < 0.25 )
