-- Find binary stars with specific colors.
-- At least one of them should have the colors of a white dwarf.   

SELECT	s1.objID as s1, s2.objID as s2		-- just count them
FROM	Star S1,				-- S1 is the white dwarf
 	Neighbors N,		-- N is the precomputed neighbors links
	Star S2				-- S2 is the second star
WHERE S1.objID = N. objID 	-- S1 and S2 are neighbors-within 30 arc sec
    and S2.objID = N.NeighborObjID  
    and N.NeighborObjType = dbo.fPhotoType('Star')       -- and S2 is a star
    and N.distance < .05			-- the 3 arcsecond test
    and ((S1.u - S1.g) < 0.4 )	-- and S1 meets Paul Szkodys color cut for
    and (S1.g - S1.r) < 0.7 			-- white dwarfs.
    and (S1.r - S1.i) > 0.4 
    and (S1.i - S1.z) > 0.4     
