Query Builder

<< Click to Display Table of Contents >>

Navigation:  User Interface Reference > Report Designer > Report Designer for WPF > Interface Elements >

Query Builder

Interface Elements for Desktop > Report Designer > Report Designer for WPF > Interface Elements > Query Builder

This document describes the Query Builder that provides a visual interface for constructing SQL queries used to access tables and views of a data source.

img124173

The document consists of the following sections.

Invoking the Query Builder

Manging Tables

Data Shaping

Data Preview

ExpandedCollapsed Invoking the Query Builder

You can invoke the Query Builder from the query customization page of the Report Wizard when creating a new data-bound report or when binding an existing one to a database. To do this, select the Query item and click the Run Query Builder... button.

img122116

You can also use the Query Builder to add queries to an existing SQL data source as well as to edit existing queries. Right-click the data source in the Report Explorer and select Manage Queries in the context menu.

img123522

The invoked Manage Queries dialog displays all queries available for the data source.

img123523

To edit an existing query, click the ellipsis button for the query you want to edit. To add a new query, click Add and in the invoked Data Source Wizard, click the Run Query Builder button.

ExpandedCollapsed Managing Tables

To add a data table to a query, select the corresponding item from the list of available tables on the left and drop it onto the list of data tables to be used.

img122798

Enable the check box for the table to add all data fields to the query. You can also enable check boxes for individual table fields you want to include in the query.

img120307

You can also add several tables in combination by a join relation to a query. Note that the Query Builder automatically highlights tables that have a relationship with any of the previously added tables. Drag-and-drop a subordinate table in the same way as a principal table to include it in a query and automatically create a relation condition based on a key column.

img124167

Another way to join tables is to click the plus img124168 button in a row corresponding to a key column.

You can then modify a join condition by clicking the ellipsis button for a table join. The invoked Join Editor dialog allows you to customize the existing relation conditions and change their types as well as add new conditions.

img124169

If tables don't have a relation at the database level, you can manually join tables. In this case, when you drag-and-drop a required table onto the list of tables to be used, the Join Editor is automatically invoked, allowing you to construct a custom join relation.

ExpandedCollapsed Data Shaping

You can assign a custom name to the selected data column by specifying its Alias in the column list displayed under the data source editor.

img124170

This list also allows you to apply sorting, grouping and aggregate functions to incoming data. Corresponding clauses are automatically added to the resulting provider-specific SQL string.

Note

You should apply aggregation/grouping to either all columns or to none of them.

To apply filtering to data, invoke the Filter Editor by clicking the Filter... button.

img124171

This editor contains the Filter tab allowing you to specify filter conditions for resulting data and the Group Filter tab allowing you to specify filter conditions for grouped and aggregated data. Note that if data is not grouped, the second tab is disabled.

The Filter Editor also allows you to limit the number of resulting data rows. To do this, enable the dedicated check box at the bottom of the editor and then specify the number of rows to retrieve in an undefined order. If data is sorted, you can additionally set how many rows to skip before retrieving the specified portions of rows.

Another option enables you to include only distinct values into the result set.

ExpandedCollapsed Data Preview

The Query Builder allows you to preview the result of the query execution in the form of tabular data by clicking the Preview Results... button.

img124172

ExpandedCollapsed See Also

Report Wizard

Bind a Report to a Database

Copyright (c) 1998-2016 Developer Express Inc. All rights reserved.

Send Feedback on this topic to DevExpress.