How to calculate the final value of a row based on another table with costs in PostgreSQL I'm new to SQL and I have two tables like those in my PostgreSQL database:

table 1 - building_specs

+-----+---------+---------+--------+
| key | wallsId | floorId | roofId |
+-----+---------+---------+--------+
| 701 |    1    |    3    |    2   |
+-----+---------+---------+--------+
| 702 |    1    |    3    |    1   |
+-----+---------+---------+--------+
| 703 |    2    |    1    |    3   |
+-----+---------+---------+--------+


table 2 - spec_value

+-------+-------+-------+------+
| value | walls | floor | roof |
+-------+-------+-------+------+
|   1   |  4,8  |  5,4  |  3,6 |
+-------+-------+-------+------+
|   2   |  7,5  |  3,8  |  7,8 |
+-------+-------+-------+------+
|   3   |  3,6  |  10,1 |  4,1 |
+-------+-------+-------+------+


I need to calculate a final value for each key in building_specs based on the values of spec_value

For example, the final_value for the line 701 in Table 1:

-> wallsId = 1 -> Reffers to value 4.8 in Table 2, Column walls
-> floorId = 3 -> Reffers to value 10.1 in Table 2, Column floor
-> roofId = 2 -> Reffers to value 7.8 in Table 2, Column roof    

Then, it should sum all referred values from table 2 and obtain a final_value of 22.7 

So, the kind of return I expect is like this:

+-----+-------------+
| key | final_value |
+-----+-------------+
| 701 |     22,7    |
+-----+-------------+
| 702 |     18,5    |
+-----+-------------+
| 703 |      17     |
+-----+-------------+


How can I do this?
If I understood your question right , you'll need something like 

select bs.key , coalesce(w.walls,0) + coalesce(f.floor,0) + coalesce(r.roof,0) as final_value 
from building_specs bs 
left join spec_value w on w.value= bs.wallsId 
left join spec_value f on f.value= bs.floorId 
left join spec_value r on r.value= bs.roofId 


Output matches 701 and 703 from the question , but different for 702 
(4.8 +10.1+3.6 != 12.2)