Database Query

Pathway: Database > Database Query


A database query is a request for specific information from modeled data sources in the database. It allows you to retrieve, export, and review data stored in the database by specifying certain criteria or conditions. After a query has been generated, the results can be exported to Excel and the query can be saved to allow users easy access to re-run the report at a future date. 


Permissions

The following permission is required to create a query:

Field Descriptions


Field Description
Saved Query    Includes a drop down selection of saved queries/reports.

New    Creates a new query.

Update    Saves any changes made to a query (added/removed fields, filters, limit/sort and etc.).

Save As    Saves the query to the system for future use. Upon saving a popup editor displays to enter a name for the query and includes a 'Public Query' check box. 
  • Public Query - if checked, the query is available for any user to view and edit. Otherwise, only the user who created the query will be able to see and use it. 
Run    Runs the query based on the selections and filters. Reports generate in a new tab.

Sections
Entities    Determines the data table the system retrieves information from. Also controls what displays for selection in the Display Fields window. 
Limit/Sort    
Optional; Controls the number of rows output and how the data is sorted when it is returned. 
  • Limit: Caps the report to only return the number of results entered. 
  • Sort: Sorts report columns in either ascending or descending order. All reports default to ascending sort order. 
Display Fields   
Data points that can be included in the query results. Fields displayed are unique to the entity selected.
  •  Display Only Selected (check box): select to only display the fields you have selected for easier review. Uncheck it to continue adding or removing field selections. 
Filters 
And/Or    Select to toggle the filter between the And/Or option to filter on. 
  • And: Requires all filter parameters in the group to be true for a record to return. Limits the report's results. 
  • Or: Requires only one of the filter parameters in the group to be true for a record to return. Broadens the report's results.
Add Group   Creates another filter group to further refine the data set that is returned.

Add Filter    Opens the 'Add New Filter' popup to define the filter parameters the report should use.

Create a Query: No Filter(s)

In some cases, users may need a simple report that pulls information from the database without a need for any filters. In that case, the following process can be used:

Create a Query with Filter(s)

Some reports require the use of a filter to refine the results to a specific data set, such as accounts assigned to a specific zip code. In scenarios similar to this, the following process can be used:

Filter Operators

Operators control how the filter will process the data and return results. Different results are returned based on the operator that is used as detailed in the examples below.

Operator Examples

Examples: Groups and Filters 

Example: Single Group, Multiple Filters (OR Statement)

Example: Single Group, Multiple Filters (AND Statement)

Example: Multi-Group with Filters

Run an Existing Query

To run an existing query, select the name of the query from the Saved Query drop down field and click 'Run'. When a query is run, it will open in another tab where it can be reviewed and exported to Excel.