The SQL block enables you to create a dataset using the SQL language SELECT statements in a Workflow.
The following demonstrates now to use the SQL block to select the variables Title and In_Stock from the input dataset lib_books.csv (which contains observations that describe a range of books available from a lending library) and output them to a new dataset.
- Import the lib_books.csv dataset into a Workflow using the Text File Import block.
- Expand the Code Blocks group in the Workflow palette, then click and drag an SQL 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 SQL Language block.
- Double-click on the SQL block to display the SQL editor view.
- In the SQL editor view enter the following:
SELECT Title, In_Stock FROM "Working Dataset";
- Close the SQL editor view and save the configuration when prompted.
A green execution status is displayed in the Output ports of the SQL block and the new Working Dataset. The dataset contains the title of all books in the library collection and whether those books are available for loan.