Association Query Example

Case Description

There are two sets of data. One contains the average temperatures and site names of meteorological stations in various cities, including provincial capitals; the other contains only provincial capitals. It is required to extract the provincial capitals and their average temperatures based on these two sets of data.

Data Description

The sample data is located in the ...\ExerciseData\Temperature folder.

  • The Temperature_July_P dataset in the Temperature.udbx data source contains the average temperature data (TemperatureAverage) for July at meteorological stations in various cities, and the meteorological site name (Name), where the meteorological site name (Name) field includes provincial capitals.
  • The ProvinceCapital_P dataset in the Temperature.udbx data source contains only the names of provincial capitals (Name).
Notes:
  • The sample data contains the above data information, but you need to download a separate installation package. For details, see Get Sample Data Package.

Main Steps

  1. Open the sample data Temperature.smwuworkspace.
  2. Click Spatial Analysis-> Query-> SQL Query to open the SQL Query dialog box.
  3. In Query data and statements, set the dataset to ProvinceCapital_P.
  4. Click the Set Associated Field... button to the right of the dataset to open the Join Attributes dialog box.
  5. In the Join Attributes dialog box, click the Add button, select the Temperature_July_P dataset in the Select dialog box, and click OK.
  6. In the Join Attributes dialog box, set both Field and Join Field to Name, the Join Method to Left Join, and click Confirm.

  7. In the SQL Query dialog box, use the Clear button in the expression toolbar to clear all expressions.
  8. In Show Results, set the Query Mode to Query Properties.
  9. Expand the Advanced group, and in the Result Reserved Fields, check Name and Temperature_July_P.TemperatureAverage.
  10. Check Save Results and use the default dataset QueryResult.
  11. Click the Query button to obtain the following results.

Related Topics

Build SQL Query

Build SQL Expression Query

Common Expressions for Building SQL Query

Function Descriptions for Building SQL Query

Attribute Query Example

Group Statistics Example