Skip to content

Applying operations to lists

You are not limited to query a single SharePoint list. Enesys SharePoint Query lets you apply specific operations between SharePoint lists.

You can define as many list statements as necessary and apply as many operations ( sqlQuery statements) as you like in order to obtain the desired Dataset from which you will build your report.

Each list statement defined within a query returns a set of data items from a SharePoint list for which we will use the generic term ” result set ”. The tableName attribute is used to give a unique name to this ” result set ”. The unique name of the result set will serve as the basis for specifying result sets involved in operations.

image

You can manipulate “result sets” by using sqlQuery statements. The data resulting from a sqlQuery statement is considered a “result set” as well and it can be further manipulated using other sqlQuery statements.

The following query shows three list statements used to retrieve data from three specific SharePoint lists as well as a sqlQuery statement used to further manipulate (join and group) the data retrieved from the SharePoint lists.

image

The SQL JOIN operation lets you join matching items between two result sets based on their joining columns. The tableName attribute lets you give a unique name to the set of data resulting from the inner join operation.

image

The following image displays a JOIN statement between the Products and the Suppliers SharePoint lists. Rather than using the supplier value pointed to by the lookup column, the query relies on the supplier ID.

image

You will notice that the “SupplierID” column has not been selected in the “Products” list. It has been automatically created by Enesys SharePoint Query for holding the ID of the “Supplier” pointed to by the lookup column.

Joining lists is useful (though not limited to that usage) when dealing with SharePoint lists linked with a lookup field.

Note that a SharePoint lookup column will return 2 columns in the resulting data for holding both the actual value and the target list item’s ID. It is recommended to join lists using those ID rather than the actual value.

You can merge two result sets by using an SQL UNION operation:

image

The DISTINCT keyword is especially useful for creating a report dataset used to set the available values of a report parameter.

Say you have a SharePoint Products list with a Category column and you would like to let the user of your report select at run time the category of products that will be displayed in the report. You can easily achieve this by creating a specific report dataset as shown in the following image:

image

Using Intellisense inside sqlQuery statements

Section titled “Using Intellisense inside sqlQuery statements”

Starting from the version 3.6, Intellisense was greatly enhanced inside sqlQuery statements.

Intellisense is provided for the following items:

The names of all the statements inside the current query (statements located before the current sqlQuery statement):

image

The Products list , RssFeed xmlQuery * and the SqlCustomers * sqlData * statements located before the current * sqlQuery * have Intellisense provided for their names. Contrary to the Employees * list * that is located after, that can’t be used inside the * sqlQuery * statement.*

The names of all the available fields inside the selected statements:

image

The only selected statement inside the query is the Products list ; the only fields available are the ones from this statement.

image

A join is made between the Products and the SqlSuppliers statements; fields from both statements are available for selection.

Code snippets for quickly adding some SQL clauses:

SELECT” code snippet

A “SELECT” snippet for inserting a SELECT clause with a FROM clause that selects a single statement.

image

By validating (with the Tab key), the snippet is inserted:

image

The statement names are available for replacement:

image

Enter/select the correct statement and click on Enter to validate the snippet modification. The caret is then moved just after the SELECT so that you can enter your selected fields:

image

Join” code snippet A “JOIN” snippet for inserting a JOIN clause with an equality condition:

image

Similarly, you have to enter/select the name of the joined statement:

image

Once chosen, click on the Tab key to move to the next placeholder that asks you for the first column used in the join:

image

Once chosen, click on the Tab key to move to the next placeholder that asks you for the second column:

image

You can move to any placeholder by clicking on the Tab key to move forward or by clicking on the Shift+Tab keys to move backward. Click on Enter to validate the modification.

All the SQLite functions and their parameters:

image

All the SQLite functions are listed with their associated parameters and a brief description.

image

Parameter description is available inside the functions when typing the characters “(” and “,”.

Note

As there is a large amount of SQLite functions, Intellisense for the SQLite functions is disabled by default as it may be difficult to find your fields within those functions. You can enable Intellisense for the functions by clicking on the following button:

image

The query is parsed in real-time in order to provide some “context” to the Intellisense provider, so that it can provide only meaningful data.

Only fields from selected statements are available:

image

Two statements are available (“Product categories” and “Products”), but none is selected inside the current SQL query, no fields are available for selection.

image

The same two statements are available but this time, “Products” is selected, its fields are available.

image

Both statements are joined, all the fields are available.

Table aliases are fully supported:

image

The name “p” is recognized as an alias for the Products statement, fields from the Products statement are available for completion.

image

The name “pc” is recognized as an alias for the “Product categories” statement, its fields are available.

Intellisense data is only available at places where it makes sense to use it.

Some examples:

image

The query being empty, only a SELECT clause makes sense right here.

image

Only statements are provided, as neither functions nor column names make sense within the FROM clause.

image

At this point, you can specify neither a table name, nor a column name, nor a function name, only the JOIN code snippet is available.

  1. I don’t have Intellisense at all.

There are several things to check:

  • Ensure that your version of Enesys RS Data Extension or Enesys IS Data Extension supports enhanced Intellisense (at least v3.6 for Enesys RS Data Extension and v1.2 for Enesys IS Data Extension ).
  • Ensure that the “Enable Intellisense” button is checked.
image
  • Ensure that some statements are located before the sqlQuery statement.

You may also read the following question if none of those checks resolved the problem.

  1. I don’t have Intellisense for one of my statements.

It may be for several reasons:

  • The statement is located after the current sqlQuery statement; therefore it can’t be used inside this particular sqlQuery statement.
  • For statements that retrieve external data (such as sqlData and xmlQuery ), it is necessary to silently execute the statement in order to retrieve the schema. If the execution failed, no error message is displayed but Intellisense is not available for those statements. Ensure that the statement is well configured and Intellisense should be available once corrected.
  • For other sqlQuery statements, it needs the query to be valid and the statements that it uses to be properly configured. Please ensure both points.
  1. No Intellisense is provided inside the sqlData * statement?*

The Intellisense feature is currently only available inside the sqlQuery statement. If you want Intellisense for SQL Server or Oracle data, we would advise you to use tools that provide Intellisense for such providers (e.g.: “SQL Server Management Studio” for SQL Server) for writing your query, then copy it back to our Query Designer.

There are some known limitations to our current Intellisense implementation, especially about subqueries.

You can use subqueries inside the FROM clause of your SQL statement.

For example:

SELECT *
FROM (SELECT DISTINCT Category FROM Products) AS DistinctCategories

In this case, Intellisense will be provided within the subquery, but no Intellisense will be provided for the DistinctCategories table inside the outer query.

You can overcome this limitation by using an intermediate sqlQuery statement that executes the subquery.

Subqueries inside the WHERE clause can use data from the outer query, as you can see in the following sample that retrieves the minimum unit price, grouped by category:

For example:

SELECT Category, UnitPrice
FROM Products p
WHERE UnitPrice = (SELECT MIN(UnitPrice) FROM Products minP WHERE p.CategoryID = minP.CategoryID)

Intellisense for the “p” table and its fields will not be prompted inside the subquery.