# Validate detail and aggregate total across tables

**URL:** https://discourse.greatexpectations.io/t/validate-detail-and-aggregate-total-across-tables/901
**Category:** Archive
**Tags:** how-to
**Created:** [October 13, 2021, 2:42pm UTC](https://discourse.greatexpectations.io/t/validate-detail-and-aggregate-total-across-tables/901 "2021-10-13T14:42:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![stephenhardy](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@stephenhardy](https://discourse.greatexpectations.io/u/stephenhardy)
#### Post date: [October 13, 2021, 2:42pm UTC](https://discourse.greatexpectations.io/t/validate-detail-and-aggregate-total-across-tables/901/1 "2021-10-13T14:42:52Z")

</div>

Hi,

I’m looking to see if Great Expectations can help with validating some rules before importing data to our product’s relational database.

One check that comes up a lot is ensuring that the totals of item details in a detail table match the aggregate total in the linked entity table.

Take Invoices and InvoiceItems for example. We’d want to ensure that the total of all Invoice items with InvoiceID = 1 matches the Total column on the Invoice with InvoiceID = 1.

Is there are suggested technique for doing this sort of check with a SQL data source?

Many thanks
