mysql sum from one of two columns
How do you get the sum from two columns, selecting only one column at a time by whichever number is smaller?
For example, you have this: col1, col2 2, 1 1, 2 2, 1 When you do the select sum query, it replies: "3". |
it's like this:
SELECT SUM( IF( col1 < col2, col1, col2 ) ) AS small_sum FROM table; |
All times are GMT -5. The time now is 12:32 PM. |