• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 6. Querying with SQL Statements > Using SQL to Create Subqueries

Using SQL to Create Subqueries

For most non-programmers who attempt to learn SQL, the subject becomes immediately worthwhile when they learn about subqueries: the capability to include a query dynaset as the criteria for another query. This is a very powerful feature that enables you to perform many otherwise difficult or even impossible query tasks.

For example, suppose you want to analyze Northwind's Products table to find out which products have a UnitPrice value that's greater than the average unit price. You know you can calculate the average unit price by using a totals query with the field expression Avg(UnitPrice). But how do you get that answer into a second query so that you can compare all the UnitPrice values with the result to see which ones are greater than the average? That sounds like a tall order, but it's actually fairly straightforward if you use a subquery.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint