Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. CKG Edit ====== ====== ===== Explanation of SQL ===== This SQL statement will pull a list of all records grouped by Order # in the GL database that have a balance in ARs. ===== Risk of Data Corruption if Run Improperly ===== **None**. This is a selection query and no data is modified in the running of it. ===== SQL ===== <code sql> DEFINE EndDate 4/30/2010 8:32:37 PM SELECT Sum(Amount) as ARAmt, OrderID FROM "GL Database" WHERE AccountCode = 1200 and DateTime < '[EndDate]' Group By OrderID Having sum(amount) > 0.005 or sum(amount) < -0.005 ;tmp1 Select OrderID ,CompanyName ,Status as Current_Order_Status ,PickedUpDate as InvoiceDate ,VoidDate ,SalesSubtotal ,TaxTotal ,SalesTotal ,TotalPayments ,BalanceOutstanding ,'[EndDate]' as AR_EndDate ,ARAmt FROM "TMP1" LEFT JOIN "Order Database" O ON TMP1.OrderID = O.OrderID LEFT JOIN "Customer Database" C ON C.CustomerID = O.CustomerID Order By O.PickedUpDate </code> ===== Version Information ===== * Entered : 6/9/2010