I struggle with a problem that i try to solve but after a couple of attempts i realised that nothing works properly and i dont have the necessary skills to do it. I am not using SQL frequently so i couldnt improve my skills. Maybe someone who is more advanced and likes this tool can help me.
In this picture i have the first table which i need to turn it to the second table
I need to multiply the rows based only on two teritory ID's : A_A and B_B. But in order for me to do that i need to do some calculation and also i need to take into consideration the country.
for example: i have Albania who has 4 teritory ID's. The only rows that i need to add is for teriory ID A_A and B_B.
To calculate the values for these 2 teritory ID, i need take into consideration only the sum of the rest of the teritory ID's that dont incluse A_A or B_B. I put the formula in the "Value" column. These are sort of ratios to split the A_A and B_B between the rest of the ID's. Also i need to rename those 2 ID's to have at the end the naming of teh ID's based on which i calculated their final values.
I really hope that someone could give me an idea.