Associated Query Example
Case Description
There are two datasets available: one contains average temperature data from meteorological stations in various cities along with site names (including provincial capitals), and the other exclusively includes provincial capital cities. The objective is to extract provincial capital cities and their corresponding average temperatures using these two datasets.
Data Description
Sample data is located in ...\ExerciseData\Temperature folder.
- The Temperature_July_P dataset in Temperature.udbx datasource contains July average temperature data (TemperatureAverage) and meteorological site names (Name), where the Name field includes provincial capitals.
- The ProvinceCapital_P dataset in Temperature.udbx datasource contains only provincial capital cities (Name).

- The sample data contains the above data information but requires a separate installation package. For details, please refer to Obtain Sample Data Package.
Steps
- Open the sample data Temperature.smwu workspace.
- Click Spatial Analysis-> Query-> SQL Query to open the SQL Query dialog.
- Set the dataset to ProvinceCapital_P in Query data and statements.
- Click the Set Associated Field... button next to the dataset to open the Join Attributes dialog.
- Click Add in the Join Attributes dialog, select the Temperature_July_P dataset in the Select dialog, then click OK.
- In the Join Attributes dialog, set both Field and Join Field to Name, select Left Join as the join type, then click Confirm.
- Use the Clear button in the expression toolbar to remove all expressions in the SQL Query dialog.
- Set Query Mode to Query Properties in Show Results.
- Expand the Advanced group and check Name and Temperature_July_P.TemperatureAverage in Reserved Fields.
- Check Save Results and keep the default dataset name QueryResult.
- Click Query to obtain the following results.
Related Topics
Construct SQL Expression Query
SQL Query Function Specifications