> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL query return rows

> Learn how to use the SQL query return rows test to validate data based on row counts

## Definition

The SQL query return rows test allows you to write custom `WHERE` conditions to filter
your data and set thresholds based on the number of rows that match your criteria. This
test counts the rows that satisfy your specified conditions and compares the count against
your defined thresholds.

You write the filtering condition without the `WHERE` keyword - the system automatically
applies it to your dataset as `df`.

## Taxonomy

* **Task types**: LLM, tabular classification, tabular regression, text classification.
* **Availability**: <Tooltip tip="Continuously evaluate your models and datasets as you iterate on their versions.">development</Tooltip>
  and <Tooltip tip="Monitor a model in production, measure its health, check for drifts and set up alerts.">monitoring</Tooltip>.

## Why it matters

* The SQL query return rows test provides a powerful way to validate data
  quality by counting rows that meet specific criteria.
* You can easily identify data anomalies, outliers, or violations of business rules
  by setting thresholds on row counts.
* This test is ideal for monitoring data consistency, detecting unusual patterns, or
  ensuring data meets expected distributions.
* It simplifies the creation of data validation rules without requiring
  complex SQL knowledge - just specify the filtering conditions.
