Skip to content
Advertisement

SQL getting the minimum out of calculation of 3 values

I have multiple rows that each have 3 columns and what I want to do is calculate these 3 columns at each row and see which row has the lowest sum

for example:

the selected row (row 3) will show me the calculated value = 2

currently I have been calculating only by 1 column but now I need 3

this is what I was doing:

my table (Bonuses)

expected results:

the row 3 is the minimum in value will print

Advertisement

Answer

you can do it with:

col1 + col2 + col3 – calculate sum of every line (row) of the table;

min(col1 + col2 + col3) – determine minimal value. In your case:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement