Jump to content

[SOLVED] mysql sum of greater of two columns....?


joel24

Recommended Posts

Not sure if this is possible in MySQL alone, however, it will greatly help my cause if it is so I'm pursuing it.

 

Say I have a table with columns like this

 

ID

Col1

Col2

1

10

20

2

20

15

3

15

30

 

Is it possible to find the sum of the greater values of col1 and col2 in MySQL... without using php etc..?

So it would be 20 + 20 + 30...

 

Any help would be greatly appreciated!

Link to comment
Share on other sites

thanks, but i need it to find the higher of each column in each row.... and add that

 

so if col1 was greater than col2 in row 23 it would put col1 in the addition, and if col2 were greater than col1 in row 12 it would put col1 in the addition there.

 

anyone?!

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.