Ian Grieve has a SQL View For Payables Transaction Distribution Accounts
SQL View For Payables Transaction Distribution Accounts | azurecurve
SQL & DataPayables & Receivables
Archived post from 2015. Dynamics GP and the links it points to have changed since; check current documentation before relying on version-specific steps.