Skip to Content
author's profile photo Former Member
Former Member

Return max value of numeric field

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 05:42 PM

    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 (,)

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.