SELECT Statement

SELECT Statement

In Microsoft Access, if you are working in SQL view in the Query window, field names (field1, field2) are used as column headings in Datasheet view. To display a different column heading for a column in the datasheet, use the AS reserved word. If you use the AS reserved word, then the alias1, alias2 arguments provide the column names to use in displaying the retrieved data in Datasheet view. The use of the AS clause is equivalent to setting the Alias property in the field list property sheet in query Design view.

The following example uses the title "Birthday" to head the column in the resulting datasheet:

SELECT [BirthDate] AS Birthday FROM Employees;

When you use aggregate functions or queries that return ambiguous or duplicate field names, you must also use the AS clause to provide an alternate name for the field. The following example creates the column heading "Head Count" in Datasheet view:

SELECT COUNT([EmployeeID])
AS [Head Count] FROM Employees;

If you are working with Data Access Objects (DAO) in Visual Basic code, the field1, field2 arguments are used to name the Field objects in the Recordset object returned by the query. If you include the AS reserved word, then the alias1, alias2 arguments provide the column headings to return as Field object names in the resulting Recordset object.