To Use the Visual SQL Query Builder to Build a Query: Example 4
- Click Clear All to clear any existing tables.
- In the Select tab page, click Tables or from the Tables menu choose Open Table.
- In the Select Table dialog, double-click Parcel.
- In the Select Table dialog, click Cancel.
-
In the Parcel dialog, double-click the Owner and Parc_area fields.
The following is in the SQL Select Statement text box:
SELECT owner, parcel_area FROM parcel
- Click the Functions option button and choose Average Value of.
-
In Parcel, double-click parc_value.
The following text is in the SQL Select Statement text box:
SELECT owner, parc_area, AVG(parc_value) FROM parcel GROUP BY owner, parc_area
-
To edit the GROUPBY clause, click the GroupBy tab page.
The GroupBy tab page opens.
- In the GroupBy Fields list box, click parc_area. Click the > (greater than) Common Operator, enter 100000 in the Value text field, and press <Enter>.
-
Click Apply to generate the following statement:
SELECT owner, parc_area, AVG(parc_value) FROM parcel GROUP BY owner, parc_area, HAVING parc_area > 100000
-
To add the OrderBy clause, click the OrderBy tab page.
The OrderBy tab page opens.
-
In the Available Fields list box, click parc_area.
The selected field appears in the OrderBy Field text box.
-
Click Apply to add a OrderBy clause to the SQL Select Statement text box.
The query in the SQL Select Statement text box is complete:
SELECT owner, parc_area, avg (parc_value), FROM parcel GROUP BY owner, parc_area having parc_area > 100000 ORDER BY parc_area
- Click Execute to display the results of the query in either a dialog form ( ) or in the Visual SQL Data Browser dialog ( ).