wiki:db/queries/042
Last modified 6 years ago Last modified on 02/01/2013 12:18:26 AM

Select diameter-limited sample of galaxies

SET @binned =   dbo.fPhotoFlags('BINNED1') +
                dbo.fPhotoFlags('BINNED2') +
                dbo.fPhotoFlags('BINNED4') 
SET @deblendedChild =   dbo.fPhotoFlags('BLENDED')   +
                        dbo.fPhotoFlags('NODEBLEND') +
                        dbo.fPhotoFlags('CHILD')
SET @blended = dbo.fPhotoFlags('BLENDED')
DECLARE @noPetro BIGINT
SET @noPetro = dbo.fPhotoFlags('NOPETRO')
DECLARE @tooLarge BIGINT
SET @tooLarge = dbo.fPhotoFlags('TOO_LARGE')
SET @saturated = dbo.fPhotoFlags('SATURATED')
SELECT run,
       camCol,
       rerun,
       field,
       objectId, 
       ra, 
       decl
FROM   Galaxy
WHERE  (flags &  @binned )> 0  
  AND (flags &  @deblendedChild ) !=  @blended
  AND (  (( flags & @noPetro = 0) 
  AND petroRad_i > 15)
        OR ((flags & @noPetro > 0) 
  AND petroRad_i > 7.5)
        OR ((flags & @tooLarge > 0) 
  AND petroRad_i > 2.5)
        OR --note, Gray changed this and to an or, becuase it did not make sense as an and.
                ((flags & @saturated  = 0 )
  AND petroRad_i > 17.5)
        ) 

This query originally came from SDSS (SX-8)