# IBM Db2 - Select rows using custom SQL
This action lets you select rows that match a custom SQL query.
Learn about some Improving the performance of SQL procedures (opens new window).
# Select rows with custom SQL
# Input fields
- SQL
- Required field
- The custom SQL statement that runs on selected rows. This generates the output datatree. <br/ ><br/ >Wrap datapills in single quote characters, <code>'</code>. <br/ ><br/ >Do not add a <code>;</code> at the end of your SQL query; this causes the step to fail. <br/ ><br/ >Do not add a LIMIT clause to restrict query size. Use the Limit input field instead.
- Parameters
- Optional field
- Assign values to your bind variables
- Order by
- Optional field
- Order of rows to return, such as <code>updated_at DESC</code>.
- Limit
- Optional field
- The maximum number of rows to return. The default is <strong>100</strong>, and the highest possible number of rows is <strong>50000</strong> rows.
- Offset
- Optional field
- The option to fetch only a page of results from the entire results set. <br/ ><br/ >For example, to skip the first 100 rows of the selected results set, input 100 to this field. <br/ ><br/ >The default is 0.
- Output fields
- Optional field
- Define the expected fields of each retrieved Document. Enables users to generate datapills for use in downstream systems, or to drive Recipe logic.
- Output CSV?
- Optional field
- Select <strong>Yes</strong> to output a CSV string of the selected data.
# Output fields
- rows
- Array of JSON objects, where each object represents a retrieved row.
- rows_count
- Number of retrieved rows.
Last updated: 9/30/2022, 8:08:55 AM