Welcome to “Joining and Sorting Lists” You can use the Query List action to join two or more lists with SQL Queries such as JOIN like LEFT or INNER Join. In this sample query, it is selecting the Customer table and left joining it to the table Agents. Since both tables have Agent Code values, the same agent codes can be queried together from the different tables.
By using the joining query above, this will have an output like the following table. Sorting Lists using Query in Collection. Using Query list action in Collection, you can perform custom sorting logic by using ORDER BY and CASE keywords.
In this example SQL Query, it is selecting the “Agents” table, and using ORDER BY CASE to specify a sorting key. The values in the “Working Area” column that matches the Value “S”, will be ordered first, followed by the values that match “H”, and values that match “B”. Followed by the rest of the letters in the Working area.
Lastly, values in the column “Commission” will be sorted in an ascending order. This sample query will have an output like this following job. It is also important to take note that only using a query action would give the values of the list in the output.
In this example, Creating a list will only contain the column names in the output of the job. Queries to alter table by adding a column will also result in the job output as empty. In order to see the final output of the table inside the collection, query the table to retrieve the rows.
This will contain all values of the table in the output job like we did in the previous lesson by using the Select Query. This brings us to the end of the lesson. In the next lesson we will look at the Common Mistakes in using Collection.