The following steps show you how to create a query and then apply it to a table (you follow the same steps when you want to apply a query to a relation):
Go into Database Manager.
Right-click your mouse and select New and then Query. The "Format Query" dialog is opened. This is where you design the new query.
In the Based On box click on Table (or on Relation if you want to base the query on a relation) and then click on the arrow in the box just to the right. The drop-down list displays all the tables in the current database. Click on one of these to select it. This is the table that the query will be based on.
Next you need to select the query components that you want to apply to the table. It may be that you have already created some of these separately in Columns, Sort Order or Filter. If so, you can click on the arrows in the boxes in the Select Query Components group box. In each case the existing components will be displayed in a drop-down list. Click on the required components to select them.
However, you may need to design the query from scratch. Notice that the "Format Query" dialog has pages for Columns, Sort Order and Filter, as well as Query. Click on the respective buttons at the top of the dialog to access these pages in turn and to design the query components. For information on designing query components, see these sections:
Rearranging columns using a columns selection
Hiding and showing columns using a columns selection
Filtering using a named filter
After you have designed and named a query component on a particular page, click on a button for one of the other pages to design another component. You will be asked if you want to create a new filter/column_definition/sort order, depending on the page. Click on Yes (alternatively click on OK if you want to apply the component immediately and close "Format Query").
You can return to a page as many times as you like to design as many components as you think you might need for future queries based on this table.
Once you have finished designing the query components, go back to the Query page of "Format Query".
In the Select Query Components group box choose the components that you want the query to apply from the respective drop-down lists in the boxes. All the query components you have just designed will appear in the lists.
Finally, give the query a name in Query Name and click on OK.
The query will be applied to your table and a Query table created. This is based on the original table, with the component conditions of the query applied.
In Database Manager the new query will appear under Queries. Whenever you are in the database you can select the query directly without having to open the original table first. The query will always reflect any changes you have made to the table. Note that the individual query components - sort orders, column views, filters - are listed under the table from which the query was designed.
Select the View SQL button to design more complex queries (see SQL Guide for more information).