Query Datasets
The
Query Datasets is
a component
build as wizard interface, which has the functionality to
create a
new
layer using a restriction clause over datasets of the
same
data source (the
where,
group by and
order by clauses of SQL). The restriction clause
can involve one or more
attributes of the same dataset, or involve more than one
dataset
and its attributes.
Basically it is possible to
make a query
through this interface, selecting the datasets involved, the attributes (properties)
desired and the restriction used to generate the new layer. The restriction clause
can involve standard attributes and/or spatial attributes, and the result can be grouped and ordered.
It is also possible to write directly the WHERE, GROUP BY and ORDER BY clauses of the SQL
command or check the SQL generated. The details will be given in the wizard pages.
It is accessible through:
Project
>
Add Layer
>
Query Dataset...
The Query layer Builder
wizard consists of the
following steps:
Wizard
Page 1 - Data Source Selector
- Choose
the Data Source type
(PostGIS, Microsoft Access, Vector File or Raster
Files) clicking over it.
- Choose
one of the Available
Data Sources by clicking over it. If the list is
empty click on
to add
a new data source before using it.
- Click
on Next to go
to the next wizard page or Cancel to close the
dialog.
Wizard
Page 2 - Dataset selection
- Name
- select which datasets will be part of the
query (it is the FROM part of a query).
- Alias - optionally change the suggested alias associated
with the dataset.
- Click on
to add this dataset name to the list and go to
the step one again to select other dataset.
- On the Data
Set list:
- Click on
to remove datasets
already selected.
- Click
on Next , Back or
Cancel to close the
dialog.
Wizard Page 3 - Attribute selection
- Available
Properties - it list all properties of the datasets
selected - choose which properties will compose the new
layer (use Ctrl and Shift keys to select them). The geometric
property is always selected and listed in Used Properties.
- Click on
move the selected properties
to the list of Used
Properties (or
to move all).
- Make use of all arrows to adjust the Used
Properties list.
- Click
on Next , Back or
Cancel to close the
dialog.
Wizard Page 4 - Where Clause Definition
- Define the WHERE clause as explained here.
- Follow the next wizard pages.
Wizard Page 5 - Group By
Definition
- Available Properties - choose which properties will be used to create groups summarizing results generated by the restriction for example.
- Use
to move/remove them to the Used Properties list.
- Click on Next to go the next wizard page, Back to review the previous one, or Cancel to close the dialog.
Wizard Page 6 - Order By
Definition
- Property - choose the property to order the query result.
- Order - choose the ordering (asc/desc)
- Click on
to add or
to remove the selected attributes.
- Click on Next to go the next wizard page, Back to review the previous one, or Cancel to close the dialog.
Wizard Page 7 - Layer
Attributes (resulting layer)
- Layer Name - Finally the user must enter a name for the new layer being created.
- Click on Finish to perform the query, Back to review the previous page, or Cancel to close the dialog.
NOTE: The SQL query command and its correspondent wizard page are given bellow:
SELECT - wizard page 3
FROM - wizard page 2
WHERE - wizard page 4
GROUP BY - wizard page 5
ORDER BY - wizard page 6