Writing SQL Statements
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
When you create a report, you usually want to display data without affecting the data itself. The SQL statement that you construct to retrieve the data will therefore usually be a SELECT statement. The following table describes the common types of SELECT queries.
|Simple SELECT||Selects specified fields (columns) from one or more tables.|
|Totals||Groups data at table level or at group level; may summarize data with SQL aggregate functions.|
|INNER JOIN||Joins two tables on a field that both have in common; results include only records (rows) for which both tables share a common value in the joined field.|
|LEFT OUTER JOIN and RIGHT OUTER JOIN||Joins two tables on a field that both have in common; results include all records from one table and only records from the other table where the joined fields are equal. Useful for finding unmatched records in two tables.|
|UNION||Returns combined result set including records from two tables that have common fields.|
|CROSSTAB||Summarizes tabular data in a columnar format.|
|TOP N, TOP N PERCENT||Retrieves the top n or n percent of values, based on the order in which the records are sorted.|
|PARAMETER||Prompts user to enter parameters for query that are used to restrict the result set.|
For more information about designing SQL statements, search the Microsoft Access Help index for "SQL statements."