Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8580787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:54:05+00:00 2026-06-11T20:54:05+00:00

And again, could any Mysql expert help me with Mysql statement? What i have:

  • 0

And again, could any Mysql expert help me with Mysql statement?
What i have: 2 tables connected with foreign keys userid and balanceID enter image description here

What I need: I need to find row where is MAX value of lets say debt and MIN value of lets say loan, What i expect from this statement is to find highest value debt and the lowest loan (1 row) for example : in this case it would be row name2 | 200 | 40. Is that possible? Have done research and couldnt find solution, any help appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:54:06+00:00Added an answer on June 11, 2026 at 8:54 pm

    Just a guess based on your minimal data set, but perhaps something like:

    select top 1 balanceID, balance, debt, loan
    from Balance
    order by debt - loan desc
    

    If you want to group by UserID, something like:

    select b.balanceID, b.balance, b.debt, b.loan
    from Balance b
    inner join (
        select UserID, max(debt - loan) as MaxDebt
        from Balance
        group by UserID
    ) bm on b.UserID = bm.UserID and (b.debt - b.loan) = MaxDebt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a question about basic mysql database optimisation. I have 3 tables, Articles,
I have two tables, which I need to join by one column and is
Again, I was creating buttons dynamically based on this post and now I need
Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve
Hello again everyone, This time I have a problem with Intent & Extras. here's
I have apache and mysql set up on my local machine (Mac). Whenever I
I have a web-app that has a master mysql db and four slave dbs.
I have blocks of HTML code in a MySQL database and my framework needs
I have a webapp written in PHP using a MySQL database backend. This question
I have a datalist that receives values from a MySQL database. This datalist can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.