MySQL user defined functions -
i have table contains few columns say: column_1, column_2 , column_3.
i appended new column table called score. want calculate score based on these 3 columns , tune parameters easily.
say score formula looks below:
score = * column_1 + b * column_2 + c * column_3 is possible create udf or process(never used before) that?
so have function getscore(a,b,c) , like:
select column_1, column_2, column_3, getscore(0.5, 0.1, 0.4) score table or
update table set score = getscore(0.5, 0.1, 0.4) thanks!
yes.
create function `getscore`(`a` decimal(12,4), `b` decimal(12,4), `c` decimal(12,4)) returns decimal(12,4) begin return + b + c; end select getscore(0.3, 0.4, 0.5) -> 1.2000 but if need values table, need include parameters too.
select getscore(column1, column2, column3, 0.5, 0.1, 0.4) score table
Comments
Post a Comment