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!

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?!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.