December 2002
Beginner
640 pages
16h 41m
English
So far today you have seen the fundamental uses of the SELECT query. You'll now see how to use this versatile query in some more sophisticated ways.
On some occasions when you're writing a query, you want to restrict the resultset on the basis of some data in the resultset that has been aggregated.
For example, suppose that you want to find, out of the table of child_products, which age range has products costing less than $10.00.
You want to write this:
SELECT age, MIN(price) FROM child_products WHERE MIN(price)<10.00 GROUP BY age
This query, if it worked, would group the products by age, use MIN() to find the minimum price in each group, and return results where the minimum ...