-- Using the BETWEEN syntax. 
-- Find galaxies with an isophotal surface brightness (SB) larger
-- than 24 in the red band, and with an ellipticity > 0.5, and with the major
-- axis of the ellipse having a declination between 30" and 60" arc seconds.
-- This is also a simple query that uses a WHERE clause with three conditions
-- that must be met. We introduce the syntax 'BETWEEN' to do a range search.

SELECT TOP 1000 ObjID 
FROM Galaxy   
WHERE r  < 24 - rho
        -- surface brightness brighter than 24 mag. per sq. arcsec in the red
	-- Note that isolating r (indexed) on one side helps this run faster
  and isoA_r between 30 and 60
        -- major axis between 30" and 60" 
  and (power(q_r,2) + power(u_r,2)) > 0.25
        -- square of ellipticity is > 0.5 squared. The SQL term 'power' is used for exponentiation.