-- Get ASPCAP parameters and targeting flags for all stars with 1 degree of a cluster center:
-- CASJobs allows search for objects near any particular RA and Dec. The
-- following example searches for ASPCAP parameters and targeting flags for
-- the stars observed near M13.

SELECT star.apstar_id,
   star.apogee_id, star.ra, star.dec, star.glon, star.glat,
   star.apogee_target1, star.apogee_target2, 
   aspcap.teff,aspcap.logg,aspcap.metals
FROM apogeeStar star
   JOIN dbo.fGetNearbyApogeeStarEq(250.423458,36.461306,60) near on
   star.apstar_id=near.apstar_id
   JOIN aspcapStar aspcap on aspcap.apstar_id = star.apstar_id
