Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsheardown/4505531ff527a3635fda8ef70b5f217b to your computer and use it in GitHub Desktop.
Save davidsheardown/4505531ff527a3635fda8ef70b5f217b to your computer and use it in GitHub Desktop.
Compare Row Count of Lines to Batch Header Count
/*
Quick query to compare a count total at header level to line count of successful rows i.e. 1 -> Many integrity check
to ensure the correct row count of lines matches header
*/
select
sph.Id,
sph.Filename,
sph.Status,
sph.CreatedAt,
case when sph.BatchRowCount = (
select
count(Id)
from
MyLines spl
where
spl.Status = 'Imported'
and
spl.HeaderId = sph.Id
) then 1 else 0 end as BatchCountMatched
from
MyHeader sph
where
sph.status = 'Imported'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment