3.5.1 Single Reference Query
The following example shows a Query that references a single table, Tasks. The purpose of this query is to return all fields of the records from the Tasks table, in descending order of date due, that meet the following criteria:
The task was scheduled to take more than 10 days.
The task is due in the next 5 days.
SELECT Tasks.* FROM Tasks WHERE (((Tasks.[EndDate])<5+Now()) AND ((Tasks.[EndDate])>10+Tasks.[StartDate])) ORDER BY Tasks.[EndDate] DESC;
<?xml version="1.0" encoding="utf-16" standalone="no" ?> <Query Name="MyQuery" xmlns="http://schemas.microsoft.com/office/accessservices/2009/04/application"> <References> <Reference Source="Tasks" /> </References> <Results> <Property Source="Tasks" All="true" /> </Results> <Restriction> =(And.Db((([EndDate])<5+Now()),(([EndDate=""])>10+[StartDate]))) </Restriction> <Ordering> <Order Direction="Descending" Source="Tasks" Name="EndDate" /> </Ordering> </Query>
The References element specifies the Tasks table is the data source for this query.
The Results element specifies that the query is returning all the fields from the Tasks table.
The Restriction element specifies an expression that selects only those records where the task is scheduled to last more than ten days and where the value of EndDate is within five days from now. The Now() function is specified in section 18.104.22.168.
The Ordering element specifies that the results are sorted in descending order based on the EndDate field.