Ensure node values are unique. If you want duplicates, store them as a count for the node with that value.
Maintain a sum for the subtree rooted at each node, inclusive of the node's total value (node.value * node.count). This is easy to maintain and doesn't add to the complexity of additions, deletions, rotations.
Code:
Example: (node.value, node.sum) // assume all node.count's are 1
10,94
5,21 15,63
3,3 7,13 13,13 17,35
6,6 18,18
Consider how to use the above info to calculate the sum from the smallest value up to a particular value, like from 3 to 6, 3 to 10, 3 to 17. You can use those sums to calculate the sum between any two values.