SQL Template

Introduction

SQL template (*.xml) records query mode, query data, group field, result, etc. You can Import the prepared SQL template, or you can Export the SQL Query dialog box to a SQL template.

The following example is how to export to a SQL template, using World.CONTINENT field and WorldWorld.COLORMAP field. See SQL Query using Group By.

Shown as follows:

Copy

<?xml version="1.0" encoding="utf-8"?>
<sqlQuery xmlns="http://www.supermap.com/desktop">
	<queryMode value="1"/>
	<sqldataset dataset="World" datasource="World"/>
	<sqlField value="World.CONTINENT as CONTINENT, World.COLOR_MAP as COLOR_MAP, Count(World.SmID) as Count"/>
	<sqlCondition value=""/>
	<sqlGroupField value="World.CONTINENT, World.COLOR_MAP"/>
	<sqlOrderby>
		<field0 value="World.CONTINENT" order="ascending"/>
	</sqlOrderby>
	<standardsql value="select World.CONTINENT as CONTINENT, World.COLOR_MAP as COLOR_MAP, Count(World.SmID) as Count from World 
    group by World.CONTINENT, World.COLOR_MAP order by World.CONTINENT asc"/>
	<showeTabular value="True"/>
	<showOnMap value="False"/>
	<showOnScene value="False"/>
	<saveResult value="False"/>
</sqlQuery>
  • : if 0, query both spatial and attribute information; if 1, only query attribute information.
  • : the datasource and the dataset to be queried.
  • : multiple fields can be set for SQL
  • : set query conditions.
  • : multiple fields can be grouped together
  • : both ascending and descending are available.
  • : SQL clauses based on parameters and conditions.
  • : whether to view the result attribute table.
  • : whether to view the result at the current map window. If the Query Mode is Attributes Only, this item is unavailable.
  • : whether to save the query result

The Group Clause

SQL Expressions

SQL Query Example

Cross Table Query

[Example of SQL Query Field Order] (SQLQuery_OrderByexample)