-- Spectra of Red Stars
--
-- SDSS-III handles searches by spectral lines differently than previous
-- releases. In addition, spectral lines for galaxies and stars are
-- identified through different processes.  See the "Galaxies with
-- Emission Lines" sample query for an example of using galaxy spectra.
--
-- Spectral lines for stars are calculated using the SEGUE Stellar Parameter
-- Pipeline (SSPP; Lee et al. 2008) and are stored in the sppLines
-- table. For more on how spectral lines of stars are found, see
-- the SSPP page of the sdss3.org website.

-- This query selects red stars (spectral type K), with large
-- CaII triplet eq widths, with low errors on the CaII triplet
-- equivalent widths.

SELECT
    sl.plate,sl.mjd,sl.fiber,
    sl.caIIKside,sl.caIIKerr,sl.caIIKmask,
    sp.fehadop,sp.fehadopunc,sp.fehadopn,
    sp.loggadopn,sp.loggadopunc
FROM   sppLines AS sl
  JOIN sppParams AS sp ON sl.specobjid = sp.specobjid
WHERE
    fehadop < -3.5
    AND fehadopunc between 0.01
    and 0.5 and fehadopn > 3


