There are basically 2 ways to write queries
Placing abcd in the Criteria of SomeField is equivalent to
WHERE SomeField="abcd"in SQL.
In general, basic SQL syntax is discussed elsewhere. This page covers some quirks which are applicable to MS Access.
Types of Queries
Aggregate Functions
In order to specify a where clause, set Total equal to Where (scroll the pick list) and make sure that the Show check box is cleared.
When the Total is set to Expression, then aggregate functions can be used in the Field definition.
Expr1: (Max([Odometer])-4388)/Sum([Gallons])
Dates
#07/01/2001# >#07/01/2001# Between #07/01/2001# And #07/01/2002#
CheckBoxes
WHERE ((([CheckBox Test].CheckBox)=False)) WHERE ((([CheckBox Test].CheckBox)=Yes)) WHERE ((([CheckBox Test].CheckBox)=0))
Renaming a Field
In the GUI, simply place the new name and a colon in front of the fieldname.
NewName: FieldName(I have seen queries where some fields can be renamed and other can not - in the same query. I have no idea why. Perhaps it only affects date fields.)
In the SQL view, use the AS operator
[TableName].[FieldName] AS NewNameIn general, AS and as are equivalent. In "real" SQL, AS is optional - however, in MS Access 97 it is required.
All computed values are named using this method. To change the default name (Expr1), simply type in a new one.
Expr1: FieldName * 2 [FieldName]*2 AS Expr1Author: Robert Clemenzi - clemenzi@cpcug.org