Creating a query

To create a query in a catalog, follow the steps below:

  1. In JReport Designer, open the required catalog, then do either of the following:
  2. In the Input Query Name dialog, give a name for the query and click OK. The Query Editor window appears. See the window.
  3. On the Query menu, click Add Table to add tables to the query.
  4. Check the columns you want in each table. To select all, click *.

    For tables in query of a MongoDB connection, you cannot select all columns by clicking *. The PrimaryKey and ForeignKey columns in each table cannot be selected to a query.

  5. Join the tables added to the query as required.

    Based on the Auto Join options that are selected in the Query Editor category of the Options dialog, JReport will join the tables automatically. However, if the pre-join feature is enabled for the data source connection where the query is created, the auto join settings will not take effect, instead, JReport applies the pre-joins to the added tables. You can also add more joins among these tables.

  6. Create filters on the query.
  7. Add some computed columns and formula fields to the query if required.
  8. Select Apply from the Query menu to save the query.

When a query has been added to a catalog, you can further edit it to suit your requirements.

Note: Normally, a query returns all the records that match its search criteria without considering whether there are duplicated ones. You can decide to get only one copy for each record by checking Select Distinct on the Query menu. When this option is enabled, SQL SELECT statements are treated as SELECT DISTINCT statements. The query will search for identical records and ensures to return them only once instead of returning duplicate records from the database. However, this feature is only supported on queries built in JDBC connections.