# Can I filter my data with a SQL query before validation?

**URL:** <https://discourse.greatexpectations.io/t/can-i-filter-my-data-with-a-sql-query-before-validation/1268>\
**Category:** GX Core Support\
**Tags:** sql\
**Created:** [July 14, 2023, 8:52pm UTC](https://discourse.greatexpectations.io/t/can-i-filter-my-data-with-a-sql-query-before-validation/1268 "2023-07-14T20:52:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![austin\_gx](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/austin_gx/32/193_2.png) [@austin\_gx](https://discourse.greatexpectations.io/u/austin_gx)\
**Post date:** [July 14, 2023, 8:52pm UTC](https://discourse.greatexpectations.io/t/can-i-filter-my-data-with-a-sql-query-before-validation/1268/1 "2023-07-14T20:52:16Z")

</div>

Can I use a SQL query in the “row\_condition” parameter in an expectations use? Is there a function where I can filter through SQL query?

---

<div class="post-metadata">

**Author:** ![austin\_gx](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/austin_gx/32/193_2.png) [@austin\_gx](https://discourse.greatexpectations.io/u/austin_gx)\
**Post date:** [July 14, 2023, 8:53pm UTC](https://discourse.greatexpectations.io/t/can-i-filter-my-data-with-a-sql-query-before-validation/1268/2 "2023-07-14T20:53:19Z")

</div>

You can [create a data asset from a query](https://docs.greatexpectations.io/docs/guides/connecting_to_your_data/fluent/database/how_to_connect_to_sql_data_using_a_query) to apply expectations to – you could also create a [Custom QueryExpectation](https://docs.greatexpectations.io/docs/guides/expectations/creating_custom_expectations/how_to_create_custom_query_expectations/) that does this filtering as a part of the metric query.
