title: SQL code to calculate purchase invoice descrepencies
body: <p>I am looking to extract records with purchase invoice discrepancies from Purchase Invoice Line [PIL], Purchase Invoice header [PIH] and Purchase line [PL], and purchase header [PH] tables.</p>
  
  <p>Do I really need to take any columns from PL AND PH at all or is it sufficient if I make use of only PIH AND PIL tables? And how to cross verify the result set at the end?</p>
  
  <p>Thanks</p>