Jump to content

Finding max of columns sum


asmith

Recommended Posts

hi

 

table  test

 

id    num1  num2  num3
1     23      21      34
2     34      32      3
.
.
.

 

is it possible to achive this : 

 

select id from test where num1+num2+num3  is maximum

 

Is there a query for this purpose ?

 

 

 

 

Link to comment
Share on other sites

i tried the second and it works. The problem is if the sum of 2 rows is equal , that query shows only 1 row. 

 

select * from table where num1+num2 are max.  --> maybe 2 rows have the max number. so i could use mysql_num_rows for it to find out . 

 

I'm looking for only one query, otherwise i can use your query, save the max sum, then again run a query ke

 

select  ..... where num1+num2+num3 = the number from previous query

 

i'm just looking for the simplest way.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.