You are Here: Articlelogy.com » Computers » Databases » Learn about Subqueries in Access Courses

Learn about Subqueries in Access Courses


Go to: Article Next Article


An understanding of queries is critical to database management. Without queries, you can't get at the information and the data is useless.

Once you master queries, a subquery is a powerful tool that greatly expands your abilities to get exactly the data you need. To unleash the real power of a subquery, you need to become familiar with SQL (pronounced "sequel"), the language of database queries. This type of knowledge, usually taught in advanced level Access courses and can make your database exponentially more powerful.

Subquery Basics
As you would learn in Access courses, a query in SQL is a SELECT statement. A subquery is simply a SELECT statement within a SELECT statement.

For example a simple query from our Access courses might read like this:

SELECT Employees.Name, Employees.Salary
FROM Employees;

This retrieves a list of employee names and their salaries from the Employees table.

A subquery from advanced Access courses could appear as such:

SELECT Employees.Name, Employees.Salary
FROM Employees
WHERE Employees.Salary IN
( SELECT TOP 5 Salary
FROM Employees AS Dupe
WHERE Dupe.Salary = Employees.Salary);

The main query pulls the same list of employees and their salaries. The subquery then takes from that list the five highest paid employees and puts them in a separate table aliased as Dupe.

Subqueries make it easy to perform such tasks as:

- Expressing values such as sales made in a given month as a percentage for all sales in the year
- List customers who haven't ordered in 60 days or employees who haven't made a recent sale
- Extract demographic data on customers from a specific state or city
- Calculate year to date totals
Problems With Subqueries

After learning how to create subqueries you will also learn some of the pitfalls to avoid.

Complex subqueries can perform quite slowly. If you find that performance is poor, try a stacked query instead. Make your first query then use the output table as the input table into the second query. Avoid nested subqueries (a query within a query within a query) as they can really drag down performance.

Subqueries that use the same table as the main query will require aliases, as demonstrated in the example above. The subquery uses the alias Dupe to make it clear it is referring to fields in the output of the main query and not in the main Employees table.

Sometimes Access just chokes on what seems to be a straightforward subquery. Verify the statement, confirming things like matching data types and that none of your names are on the reserved words list. Rewrite the query or, if necessary, break it into stacked queries.

Subqueries are incredibly powerful and flexible tools for data access but can also be a source of frustration and error if used incorrectly. Though they can be complicated, you may be amazed at how much more control you have over your data once you master this knowledge.
Article Source: Articlelogy.com
- Credit Cards A big selection of Cards in all flavors: Bad Credit Cards, Secured Cards, Prepaid Cards, Credit Cards for Canada, Low Interest Cards, etc -


Word Count: 529




Reduce Your Debts Without Bankruptcy. See How Much You Can Save. Free Debt Analysis



Read Article ~ Read Next Article
 


Selected Articles

1: Public Car Insurance in Canada
2: Monthly Car Insurance
3: Why Compare Vehicle Insurance Quotes
4: Way to Get your Unique iPhone Apps Developed
5: Why Do I Need to Attend a Fitness Resort?
6: Contact Lenses Online: Convenient, Less Time Absorbing, Order On The Spot
7: Want Assist With Internet Marketing? Try These Suggestions
8: The Foam Filled Chairs Are Perfect Items of Furnishings
9: People clinging to their content sending dcma requests
10: The Enormous Bean Bag is low priced along with a top quality item of furniture
11: Tips on how to Handle Cholesterol Levels to be Healthful
12: A good solid Global One Ultimate Power Profits Paradigm Shift Platinum Superbly Inspection
13: Car Maintenance: Much better Than Auto Repair St. Louis Case
14: Choosing B&b Hartbeespoort Dam
15: Melaleuca- An Impartial Review- So is this a Melaleuca Scam or can you honestly generate income with this business?
16: Los Ciclos Grado Medio en Catalunya interesan a los estudiantes
17: Tips To Start Successfully Marketing On the web Today
18: Prescription Assistance Programs, Goal and Rewards
19: Way to Find an Efficient SEO Service Provider
20: Joomla Development for your Website
21: Website Design Graphics for Niche Businesses
22: Recycling Help in Keeping our Environment Thoroughly clean
23: Nashville Recycling Info for the Folks of Nashville
24: Personal computer Restoration - Suggestions for Locating a Dependable provider at Waukesha
25: Would like To order Tunes On-line?
26: Viviane Skincare- A Completely Independent Assessment By an Expert
27: Dallas Texas HCG Diet plan Protocol
28: HCG Diet Protocol, it genuinely Succeeds
29: The Functions for Charter Jets
30: Try Out the Well known Athlete's Alfredo with Homemade Alfredo Sauce recipe
31: The Broccoli Cheddar Spinach Soup Recipe Is easy To Actualize
32: Technology Consulting Overview
33: Join the opportunity Get Pre-launch Immediately And Tie down Your Place
34: Beneficial Suggestions For Achieving Article Marketing Results
35: Why should you opt for promotional pens?
36: Types of stress relievers to keep you hale and healthy
37: Mistakes to avoid while choosing novelty pens


Read Article ~ Read Next Article

You are Here: Articlelogy.com » Computers » Databases » Learn about Subqueries in Access Courses