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

  1. Choose the Data Source type (PostGIS, Microsoft Access, Vector File or Raster Files) clicking over it.
  2. 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.
  3. Click on Next  to go to the next  wizard page or Cancel to close the dialog.

    Wizard Page 2 - Dataset selection

  1. Name -  select which datasets will be part of the query (it is the FROM part of a query).
  2. Alias - optionally change the suggested alias associated with the dataset.
  3. Click on add dataset to add this dataset name to the list and go to the step one again to select other dataset.
  4. On the Data Set list: 
    1. Click on remove icon to remove datasets already selected.
  5. Click on Next , Back or Cancel to close the dialog.

    Wizard Page 3 - Attribute selection

  1. 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.
  2. Click on right arrow move the selected properties to the list of Used Properties (or right_all arrow to move all).
  3. Make use of all arrows to adjust the Used Properties list.
  4. Click on Next , Back or Cancel to close the dialog.

    Wizard Page 4 - Where Clause Definition

  1. Define the WHERE clause as explained here.
  2. Follow the next wizard pages.

    Wizard Page 5 -  Group By Definition

  1. Available Properties - choose which properties will be used to create groups summarizing results generated by the restriction for example. 
  2. Use to move/remove them to the Used Properties list.
  3. 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

  1. Property - choose the property to order the query result. 
  2. Order - choose the ordering (asc/desc)
  3. Click on add to add or remove to remove the selected attributes.
  4. 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)

  1. Layer Name - Finally the user must enter a name for the new layer being created.
  2. 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