-- Finding galaxies by their emission lines:
--
-- 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 "Spectra of Red
-- Stars" sample query for an example of using stellar spectra.
--
-- Spectral lines for galaxies are calculated using the MPA-JHU
-- spectroscopic reanalysis (Tremonti et al. 2004; Brinchmann et al. 2004)
-- and are stored in the galSpecLine table. For more on how spectral lines
-- of galaxies are found, see the Galspec page of the sdss3.org website.
--
-- This query selects galaxy spectra with high internal reddening,
-- as measured by the standard Balmer decrement technique. It
-- makes use of the galSpec tables for the measurements of
-- galaxy lines. In this case we use galSpecLine, which has
-- emission line measurements.

SELECT
    s.plate, s.fiberid, s.mjd, s.z, s.zwarning,
    g.h_beta_flux, g.h_beta_flux_err,
    g.h_alpha_flux, g.h_alpha_flux_err
FROM    GalSpecLine AS g
   JOIN SpecObj AS s ON s.specobjid = g.specobjid
WHERE
    h_alpha_flux > h_alpha_flux_err*5
    AND h_beta_flux > h_beta_flux_err*5
    AND h_beta_flux_err > 0
    AND h_alpha_flux > 10.*h_beta_flux
    AND s.class = 'GALAXY'
    AND s.zwarning = 0

