The SQL Query feature in SuperMap allows grouping search results based on one or multiple specified fields, grouping records with identical values in the specified field(s).
Single Field Grouping
Using the Province_R dataset from the sample data PopulationAndEconomy as an example, this section demonstrates grouping statistics for province counts in eastern, western, central, and northeastern China.
- Open the PopulationAndEconomy sample data source in Workspace Manager.
- Select SQL Query from the Spatial Analysis tab -> Query group.
- In the SQL Query dialog, select PopulationAndEconomy as the data source and Province_R as the dataset.
- Click the Clear button in the expression toolbar to empty the expression input box.
- Check Query Properties in Show Results.
- Set Group Field to Class under Advanced settings.
- Enter Class, Count(SmID) as ProvinceClassCount in Result Reserved Fields.
This preserves the Class field in result data. The system calculates province counts per group based on the Class grouping field and saves results in the ProvinceClassCount field.
- Click Query to display the result table window as shown:
Multi-Field Grouping
Select multiple fields in the Group Field dropdown or manually input them. The application will first group records by the first specified field, then subgroup by subsequent fields.
Continuing with the Province_R dataset, this example performs subgroup statistics based on region and map color.
- Open the PopulationAndEconomy sample data source in Workspace Manager.
- Select SQL Query from the Spatial Analysis tab -> Query group.
- In the SQL Query dialog, select PopulationAndEconomy as the data source and Province_R as the dataset.
- Click the Clear button in the expression toolbar to empty the expression input box.
- Check Query Properties in Show Results.
- Enter Class in Sort Field and select Ascending order. This sorts results by the Class field.
- Input Class,ColorID in Group Field. This creates primary grouping by Class and secondary grouping by ColorID.
- Enter Class, ColorID, Count(SmUserID) as ProvinceCount in Reserved Fields.
This preserves Class and ColorID fields in results. The system calculates province counts per subgroup and saves results in the ProvinceClassCount field.
- Click Query to display the result table window as shown:
Related Topics
Construct SQL Expression Query