The Query block enables you to create SQL code that you can use to join database tables or datasets, to get specific data from one or more database tables or datasets.
The following demonstrates how to use the Query block to select rows from the input dataset lib_books.csv (which contains observations that describe a range of books available from a lending library) that contain the title of a book by a particular author that is no longer in the library.
- Import the file lib_books.csv into a Workflow using the Text File Import block.
- Expand the Data Preparation group in the Workflow palette,then click and drag a Query block onto the Workflow canvas.
- Click the Output port of the Lib Books dataset block and drag a connection towards the Input port of the Query block.
- Double-click the Query block to display the Query Editor view.
- In the Tables panel, in the Working Dataset, double click Title and then In_stock.
- The Title and In_stock rows are added to the Columns panel.
- Ensure the columns are included in the query by selecting Select, if necessary.
- Enter the following in the Where box:
author EQ "Rendell, Ruth" AND In_Stock EQ "n"
- Close the Query Editor view and save the configuration when prompted.
A green execution status is displayed in the Output ports of the Query block and the new Working Dataset. The dataset contains the books written by Ruth Rendell that are no longer in the library collection.