Creating SQL queries by using the visual query builder


Important

The features and enhancements in this topic are under controlled availability to participating customers.

The visual query builder is a query editor that you can use to create SQL queries for the Service Management query type. The editor provides the views and fields to quickly build queries. Unlike the SQL and form methods that require a good understanding of SQL and related concepts, users without any prior knowledge of SQL can create queries by using the visual query builder.

The editor contains views of BMC Helix ITSM objects, such as incident, change, and problem management. These views are displayed as folders. The views include fields that you can add to the query. These fields are mapped to the BMC Helix ITSM database tables. You select the required view and fields on the editor UI, and the SQL query is generated automatically.

The visual query builder supports the following BMC Helix ITSM views and field types:

Views

  • Archived incidents
  • Asset management
  • Business workflows
  • Change management
  • Configuration management
  • Incident management
  • Problem management
  • Service level management
  • Service request management
  • Task management
  • Work order management

Field types

23.4_vqb_dimension_field.png Dimension: These fields are text or data fields that are used to describe data.

23.4_vqb_metric_field.png Metric: These fields are used to measure numeric values, such as count and average.

23.4_vqb_calculated_field.png Calculated: These fields are used as filters with predefined values.

icon_enum_values_rms.pngEnum: These fields contain a set of constant values to choose from.

The following process flow explains the steps involved in creating queries by using the visual query builder.

23.4_query_creation_process_vqb.png

Before you begin

Make sure that BMC Helix Dashboards is connected to BMC Helix ITSM.

To create queries by using the visual query builder

  1. On the Home page, click Add Visualization.
  2. From the Data source list, make sure that BMC Helix is selected.
  3. From the Query type list, select Service Management.
  4. From the Type list, select Visual query builder.
  5. On the Visual query builder page, perform these steps:
    1. From the View list, select the required view.
      After you select the view, the left pane shows the fields that you can use to build the query. The fields are listed under view folders.

      24.1_vqb_views_fields.png

    2. Select a view folder and drag the required fields to the Fields area.
    3. (Optional) To add the distinct statement to the query, select Use distinct.
    4. Click Preview.
      The query is built and the results of the query are displayed in the table view.

      24.1_vqb_query.png

    5. (Optional) Add filters to view the subset of data fetched by the query.
      For details, see To add filters to restrict data.
    6. (Optional) Aggregate data fetched by the query.
      For details, see To aggregate data.
    7. (Optional) To make changes to the query, select and remove fields as required and preview the changes.
      Note: You can remove fields by dropping them to the left pane in the list of fields.
    8. (Optional) To change the sequence of fields, drag the fields to move them to the required position.
    9. Click SQL to view and verify the generated query.

      24.1_vqb_preview_query.png

    10. Click Use query.
      You are directed to the panel configuration options and the query is copied in the query box.

      24.1_vqb_use_query.png

  6. (Optional) To make changes to the query, perform any of these steps:
    1. Click Query Builder and make changes.
    2. From the Type list, select SQL and manually edit the query.
  7. (Optional) To remove all the existing view and field selections, click Reset.
  8. Apply visualizations and data transformations. For details, see Configuring-dashboards-panels-and-queries
  9. Save the dashboard.

To add filters to restrict data

You can add filters to limit the amount of data that is returned by a query. Data is filtered based on the filter conditions that you specify. You can define conditions by using the operators; for example, define the following condition to view data only for the HR group: Group contains or equals HR

The following operators are supported to define filter conditions:

Operator

Description

Type

Greater than

Greater than a single alphanumeric or string value.

Numeric

Less than

Less than a single alphanumeric or string value.

Numeric

Equal

Equal to a single alphanumeric or string value.

Alphanumeric

Greater or equal

Greater than or equal to a single alphanumeric or string value.

Numeric

Less or equal

Less than or equal to a single alphanumeric or string value.

Numeric

Exact match

Matches exactly with a single alphanumeric or string value.

Alphanumeric

Contains

Record contains the filter text.

Text

Does not contain

Record does not contain the filter text.

Text

Begins with

String starts with a letter or letters.

Text

Ends with

String ends with a letter or letters.

Text

Is null

Record contains no value for selected attribute. No parameter can be set.

NA

Is not null

Record contains any value. No parameter can be set.

NA

In

One or more alphanumeric or string values.

Alphanumeric

To apply filters

  1. Open the visual query builder.
  2. From the View list, select a view.
  3. Drag the required fields to the Fields area.
  4. Drag the fields to be used as filters to the Filters area.
    Note: You can drag fields from Fields to Filters. The enum-type fields display a set of constant values. You can select a value instead of typing it manually.
  5. (Optional) Drag the calculated fields to be used as filters to the Filters area.
    For more information about calculated fields, see the Using calculated fields as filters video.

  6. Define filter conditions for the fields by using the operators.
  7. Preview and use the query.

Example

Bob is a dashboard user. He wants to view the problem summary and other details, such as impact, priority, urgency and assigned groups. He selects the Problem Management view and selects the specified fields under Problem Details. He previews the query and decides to apply the filter to view only critical queries. He applies the following filter:

24.1_pm_filter.png

Bob can now analyze the critical problems.

Query without the filter

24.1_pm_data.png

Query with the filter applied

24.1_pm_filtered_data.png


To aggregate data for analysis

You can aggregate data returned by a query. Use data aggregation to summarize data for useful analysis. The following aggregation functions are supported:

Aggregation function

Description

Data type

Average

Average of values returned by the query.

Numeric

Count

Count of items returned by the query.

String and numeric

Sum

Sum of all values returned by the query.

Numeric

Maximum

Maximum value out of total values returned by the query.

Numeric

Minimum

Minimum value out of total values returned by the query.

Numeric

Count Distinct

Count of distinct items returned by the query.

String and numeric

To aggregate data

  1. Open the visual query builder.
  2. From the View list, select a view.
  3. Drag the required fields to the Fields area.
  4. Click the required field and select an aggregate function.
  5. Preview and use the query.

Example

Carl is a Service Desk manager. He wants to view the incidents according to assigned groups. He selects the Incident Management view and drags the Incident Number and Assigned Group fields under Incident Details to the Fields area. He previews the query. The query results show the incident ID according to assigned groups. However, he wants to view the count of incidents for each assigned group. He uses the following Count aggregate function and previews the query:

24.1_im_data_filter.png

Query without the count aggregation function

24.1_im_data.png

Query with the count aggregation function applied

24.1_im_query_with_count_aggregate.png

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*