SQL Tutorial: Practice Using Aggregate Functions, Group By, and Order By
SQL Tutorial
SQL Tutorial
 Back to Help
 1. Introduction
 2. A Simple Query
 3. Common Searches
 4. More Samples
 5. Multiple Tables
 6. Aggregate Fcns.
 7. Group By
 8. Order By
 10. Functions
 11. Conclusion

Practice Using Aggregate Functions, Group By, and Order By

Write queries to answer the astronomy questions in Practice 7, 8, and 9. Use the Schema Browser when you need it.

Practice 7. What are the northernmost and southernmost objects with spectra measured by the SDSS?

Practice 8. What is the redshift of the nearest galaxy whose spectrum was measured by the SDSS with high (35%) confidence? Use the equation

cz = H0d

to find the distance to the galaxy in light-years. The speed of light, c, is 1 light-year per year. The constant H0, called the Hubble constant, is about 70 km/s/Mpc, or
7.11 x 10-11 / yr.

Compare the distance you found to the distances to the Andromeda Galaxy (2 million light-years) and the Whirlpool Galaxy (37 million light-years). Does the distance you found seem reasonable?

Practice 9. What field has galaxies with the highest average redshifts in run=1458, camcol=1?

Be sure you are searching fields (as run-camcol-field) for galaxies. Also look at how many spectrally measured galaxies are in the field - make sure you don't pick a field with only one or two galaxies! Also, note that this query will probably take a long time to execute.

Each practice question can be answered in different ways, but here are some Sample Answers.

Notice that these practice questions have gotten more difficult, and are more like the questions that astronomers really ask in their research. You're getting better in your searches!


Enter your SQL query in the text box. The query is limited to 90 seconds and 100,000 rows.