Use this query to find orders with negative balance due. This is usually due to a bug whereby payments could be doubled (really entered twice without refreshing) or even tripled. This query finds those affected orders.
None. This is a selection query and no data is modified in the running of it.
SELECT OrderNumber, TotalPrice, PaymentTotal, CreditMemoAmount, BalanceDue, StatusText, OrderCreatedDate, SaleDate, (SELECT SUM(Amount) FROM GL WHERE TransactionID = TransHeader.ID AND GLAccountID = 14) AS ARBalance, FROM TransHeader WHERE BalanceDue < 0 AND TransactionType = 1 ORDER BY OrderNumber DESC