Query structure
Understanding how queries are built by Cognos Analytics helps authors create queries that have a minimal effect on performance.
The Basic SQL query syntax contains looks like this:
SELECT
<column 1>
<column 2>
etc...
FROM
<table or view 1>
<table or view 2>
etc...
WHERE
<clause 1>
AND <clause 2>
etc...
You can view this structure in the SQL code that is generated by Cognos. See Analyzing native SQL from your report for details.
These clauses can be seen when examining the generated SQL code:
- SELECT
- All query items listed in the Data Items section are columns that are displayed in the SELECT clause of a query.
- FROM
- The tables and views used in the FROM clause in the query can come from either the metadata model, nested tabular queries, SQL, or joins.
- WHERE
- WHERE clause items are listed in the Filters section. The AND operator is applied to multiple filters. If the OR operator is required between two WHERE clauses, then you must embed both within the same filter and separate them with the OR clause manually.