SQL statement for an Advanced report or retrieval

On the SQL tab of the Retrieval Settings screen, you must enter an SQL query to return values from one or more tables in the current database connection.

Note: If you need to return values from a data source that is not in the current database connection, you can use the Design screen to set up the query to another data source.

The query you enter on this tab must be a SELECT statement. The Dynamic Reports module will not execute an INSERT, UPDATE, DELETE, DROP, ALTER or CREATE statement or any stored procedure.

 

Contents  [Hide]

 

Tips for beginning the SQL query

If you will be querying one or more tables for GainSeeker data, standards or processes, there are two shortcuts that you can use to begin the query for you:

Note: Some retrieval settings from SPC and DMS reports will not be automatically translated into the SQL query. These include:

  • columns that are calculated from fields in the database records, such as X-bar, Range, Sigma, Moving range, p, u, and Row number

  • the Maximum count for an SPC report

Entering and editing the SQL query

You may click in the text window on the SQL tab and type the full SQL statement.

For help with SQL commands and reserved words, table names and column names:

  1. Click to place your cursor in the position where items should be pasted into the statement.

  2. Right-click in the text window and select an option – Reserved Words, Tables or Columns – from the right-click menu.

    Each option presents a list of items that can be pasted to the location of your cursor in the text window.

  3. Select one or more items from the list, and then click OK.

Reserved Words

Reserved Words perform specific tasks in SQL.

Clicking this option displays a list of the most commonly-used Reserved SQL Words.

To display a longer list of reserved words, select the Show ALL check box.

To reduce the number of items displayed in the list, enter any portion of the item's name into the Search box. As you type, GainSeeker will automatically hide from the list any items that do not contain the text you have entered. To return to the full list of items, remove all text from the Search box.

To paste one or more reserved words into your SQL statement, select one or more items on this list and then click OK.

Tables

The current database connection references a database. To quickly access the names of the tables in this database, click Tables on the right-click menu.

This displays a list of tables in this database.

To reduce the number of items displayed in the list, enter any portion of the item's name into the Search box. As you type, GainSeeker will automatically hide from the list any items that do not contain the text you have entered. To return to the full list of items, remove all text from the Search box.

To paste a table name into your SQL statement, select an item in the list and then click OK.

Columns

For any table available to the data source, you can quickly access the names of all columns in that table. Click Columns on the right-click menu.

This displays a screen that allows you to choose column names for any of the tables available to the selected connection.

  1. Click the Table list and select the name of the table for which to find column names.

  2. Select one or more items from the Columns list, and then click OK. The column names you selected are pasted into the SQL statement.

To reduce the number of items displayed in the list, enter any portion of the item's name into the Search box. As you type, GainSeeker will automatically hide from the list any items that do not contain the text you have entered. To return to the full list of items, remove all text from the Search box.

  1. To access column names from another table, repeat these steps.

Testing the SQL query

To test the SQL query you have entered on the SQL tab:

  1. Click the Test tab.

  2. You can reduce the amount of time and system resources that are needed to test the query by selecting the Limit test to 5 rows check box. If you want to see all of the rows returned by the query – even if this means waiting for thousands of rows to be returned – clear the Limit test to 5 rows check box.

  3. Click Test Query.

If your query was successful, it will return a data set like the example below.

You should review the data set to make sure it reflects your intentions for this report.