on 11-20-2007 4:58 PM
Post Author: misslora
CA Forum: Formula
Database field is character. Converted to numeric via formula.
Would like to select only those records with the max value for the numeric field.
Two tables: Customer and payment tables
Customer table has customer ID and and order ID. Payment table has customer ID and payment id. The customer has only only customer id but could have multiple order ID's that are used to link the customer back to the Order table.
When running a report for customer payments, I get multiple rows for the same payment when the customer has multiple order ID's. I'd like the report to resolve the duplicate by assessing the max order ID and returning only the one payment.
Post Author: Lugh
CA Forum: Formula
The simplest solution is to do this in your SQL query:SELECT Pay.CustomerID, Order.OrderID, Pay.PaymentIDFROM PayLEFT JOIN OrderON Pay.CustomerID = Order.CustomerIDWHERE Order.OrderID IN (SELECT Max(OrderID) FROM Order WHERE Order.CustomerID = Pay.CustomerID) If you can't manipulate the SQL, there is another option. Group the records by the CustomerID of the Payment table. Set up a formula to suppress the details section if <> Maximum (,)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.