Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to select multiple maximum values from the same table ?

    Hi !!!!
    How do I select the greatest value in the date_paid column belongs to a specific loan_ref_id?

    For example in the below diagram
    2014-05-29 12:50:29 is the greatest date_paid for loan_ref_no 91 and
    2014-06-02 17:49:03 is the greatest date_paid for loan_ref_no 92
    How to select multiple maximum values from the same table ?-max.jpg

    Thanks in advance !!!!!

  • #2
    New Coder
    Join Date
    Jun 2005
    Location
    Blackpool. UK
    Posts
    98
    Thanks
    0
    Thanked 4 Times in 4 Posts
    SELECT MAX(columnA), MAX(columnB) FROM table WHERE id=criteria;
    Chris

    Indifference will be the downfall of mankind, but who cares?

  • #3
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,944
    Thanks
    2
    Thanked 170 Times in 165 Posts
    Code:
    select loan_ref_id, amount_paid, max(date_paid) as date_paid from table group by loan_ref_id;


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •