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

Practice Using Functions

Write queries to answer the astronomy questions in Practice 10 and 11. Use the Schema Browser when you need it.

Practice 10. In the field 756-6-525, what percentage of all objects detected by the SDSS are too close to the edge of their fields to be trusted?

Hint: Use two searches, one with a flag and one without. Search run=756, camcol=6, field=525.

Practice 11. Choose a galaxy cluster from SkyServer's Famous Places tool. Write a query to select galaxies in the cluster, and only galaxies in the cluster.

Hint: After you pick a cluster, use the Navigation Tool to examine the cluster. Guess which galaxies belong to the cluster - you should be able to tell just by looking. Click on 5-10 cluster galaxies and save them in your online notebook. Open the notebook, and look for features that the cluster galaxies have in common. Guess the center position and radius of the galaxies. Then, write a query that uses what you have learned to search for cluster galaxies.

Answers

An Afterthought: Procedures and Constants

In addition to tables, views, and functions, the Schema Browser contains entries for procedures and constants. Procedures, like functions, are mini-programs that the database can execute. Unlike functions, they do not output a single value; rather, they manipulate the inputs passed in to them. Procedures are called with the syntax

dbo.spProcedurename(inputs)

Nearly all of the procedures in SkyServer are used by the web server or tools - you will hardly ever use them in your queries. If you ever need them, the Schema Browser will tell you what they do and how to use them.

Constants are, well, constant. They can be displayed and searched just like tables can. See the Schema Browser for a complete description of SkyServer's constants.

You're done! Click Next for the conclusion.


Format HTML XML CSV

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