Hello everyone, I have a monthly process where I get a table on which I need to perform a transformation that goes by adding the variable M1 and M2 of each branch. The problem is that from month to month I can have more or less branches, so my variables can vary, which makes it difficult for me to create a simple query to add variables having previously declared them. I need some procedure that knows it should sum variable starting with M1 with variable starting with M2, by branch name, also being prepared to changing number of branches (variables) from month to month. Below I have two tables, which I hope will allow you to understand what my problem is. Additionally, I give you two other tables that will be the desired result. August Input: TYPE M1_BRANCH1 M1_BRANCH4 M1_BRANCH9 M2_BRANCH1 M2_BRANCH4 M2_BRANCH9 CASH 10 20 15 15 20 30 August desired Output: TYPE BRANCH1 BRANCH4 M1_BRANCH9 CASH 25 40 45 September input: TYPE M1_BRANCH1 M1_BRANCH4 M2_BRANCH1 M2_BRANCH4 CASH 10 20 15 20 September desired Output: TYPE M1_BRANCH1 M1_BRANCH4 CASH 25 40 Thank you so much for your help. Corrected the desired output for september.
... View more