So you are given 2 accounts whose total money sums up to $31,500. So let the first account have x dollars in it while the second account has y dollars in it. Since the sum of the two accounts is $31,500 you have...
x + y = 31,500
By rearranging the equation, you can get the y value (the money in the second account) to be in terms of x (the money in the first account) by just subtracting x from both sides of the equation.
y = 31,500 - x
So now how have 2 variables that are in terms of x, which are ...
x [the money in the first account] & (31,500 - x) [the money in the second account]
You are also given that the first account gained 11% of its value while the second account lost 9% of its value, but your total earnings amounted to 865, so you have the equation...
1.11x - 0.09(31,500 - x) = 865
By multiplying the first account by 0.11, that will give you the money that the account has gained after its 11% return. Multiplying the second account by 0.09 will give you the amount of money that the second account lost after its 9% loss. So your gains minus your losses amounts to the $865 that you earn in the end. When you solve the equation for x, it will give you the money in the first account.
0.11x - 2,835 + 0.09x = 865 (distributing the 0.09 into the parenthetical expression)
0.20x - 2,835 = 865 (add like terms)
0.20x = 3,700 (add 2,835 to both sides)
x = 18,500 (divide by 0.20 on both sides)
Now we have just solved for the money in the first account, but still need solve for the money in the second one. According to our earlier expression, 31500 - x = the money in the second account, so...
31,500 - 18,500 = 13,000