I am trying to calculate column based on other columns from many tables and then I have to order my results based on this column
Table users
id_user, module1, module2, module3 ...
Ex
user1, option1, option2, option2
user2, option2, option1, option2
user3, option1, option1, option1
user4, option1, option1, option1
Tables module1, module2 .... have options from 1 to 20 so instead of
user1, option1, option2, option3
it may as well be
user1, option15, option15, option15
Table module1
id1, id2, value
Ex
option1, option1, 10
option1, option2, 5
option1, option3, 8
option1, option4, 9
option2, option2, 10
option2, option3, 7
option2, option4, 2
Table module2
id1, id2, value
Ex
option1, option1, 8
option1, option2, 6
option1, option3, 7
option1, option4, 4
option2, option2, 9
option2, option3, 7
option2, option4, 1
Table module3
id1, id2, value
Ex
option1, option1, 9
option1, option2, 6
option1, option3, 5
option1, option4, 10
option2, option2, 9
option2, option3, 3
option2, option4, 7
What I need is to calculate for ex the total value for
(user1,user2) = module1(1,2) + module2(2,1) + module3(2,2)
= module1(1,2) + module2(1,2) + module3(2,2)
= 5 + 6 + 9 = 20
And then for user1
and all the other users
and order by total value
Thank you, Monica