Identifying Payables Transactions with Missing Apply Records

This is a reposting of an article I originally wrote on my Developing for Dynamics GP blog.
From the Useful SQL Scripts Series.
I was assisting on a support case recently where we needed to identify transactions in Payables Management history which had missing Apply records. We wanted to add up the total of the Apply records and make sure that they matched the value of the original document amount.
