Navigation:  Query Builder > Query Types >

Dynamic Sample Set Query - Example [HGA+ only]


In HGA+, dynamic sample set queries are used to find sets of samples meeting specific conditions. The sample sets that are created this way are called "Dynamic" because the samples in the group may change as data is added/edited in the database. Alternatively, the "Static Sample Sets" are so-called because they are based on a fixed list of samples selected from the Sample List view and they do not change unless you manually add/remove samples from the list. Sample Sets are mainly used in the HGA+ modules including as source data for Plot Collections, Sample Reports, R-scripts; however, they can also be used in other modules that work with queries.

Follow the steps in the example below (using the Demo project) to create a Dynamic Sample Set.


Creating a Dynamic Sample Set Query (Example)

If the Query Builder tab is not yet opened, select the Query Builder icon from the main toolbar.

In the Query Builder tab toolbar, select the New button and the New Query dialog will appear.

The default Query Type is the General Query - we need to change this by selecting the Dynamic Sample Set option.

Provide a Query Name: Samples with Exceedances.


Select OK to create the query.        You will notice that the Display Fields and the Group Conditions sections have become disabled - these are not available for Dynamic Sample Set Queries.


Click on the button to load the Condition dialog:

The Condition dialog allows you to create parameter-based conditions, including measured, calculated, station, and sample parameters. These can also be include conditions based on Water Quality Standards. Some example conditions include:

samples collected from a station of a particular type (e.g. Station Type = Observation Well)

samples collected in a given year (e.g. Sample Date >= Jan 1, 2008 AND Sample Date < Jan 1, 2009)

samples with exceedances (e.g. Benzene >= MCL for Benzene)

samples with a specified concentration above

samples with below a given calculated hardness (e.g. Hardness <= 50 mg/L CaCO3)

samples with below a given calculated hardness (e.g. Hardness <= 50 mg/L CaCO3)


To illustrate, we will create a sample set with the first three of these conditions:

Select Parameter value

Change the parameter by clicking the button to open the parameter selector, select Station parameters from the drop down and "Station Type" from the list:


Click OK

Type Observation Well in the condition textbox:


Click OK

Add a second condition by clicking the button

Change the parameter by clicking the button, select Sample parameters from the drop down and "Sample Date" from the list:


Click OK

Enter a Date value of Jan 1, 2008:


Click OK

Repeat the steps above but enter a condition for samples collected before Jan 1, 2009:


We will now add one last condition. This time, we will add a condition based on a water quality standard exceedance:

Click the button

Select "Exceeds Standard" from the top dropdown menu and select the "The following parameter" option

Change the parameter by clicking the button, select Analyzed parameters from the drop down and "Benzene" from the list:


Click OK

Select the EPA RSL - MCL as the applicable standard.  The Condition window should look like the following:


The conditions pane of your query should now contain a total of four conditions:


Note that there are three validation errors () since SQL requires a logic gate between conditions.  We will specify the AND condition for each:


Click the Save button to save the Sample Set. Note that the Sample Set is now saved in the Project Tree and will be available for use with other modules.:



Select the Execute Query button and you will be moved Sample List which will now contain only those samples that meet the conditions specified in the Dynamic Sample Set query:




More useful is the fact that the new query will now appear as a new branch under the Station Group branch in the Project Tree and is available for use with other modules.



Page url: