I am having a lot of Trouble with a Scenario that i think some of you might have come across.
(the whole Thing is about Business Trips, two tables, one filled with payments done on Business trips, and the other is about the Business Trips, so the first one has more Rows than the other, (there are more Payments that happened than Trips)) I have two tables, Table A and Table B.
Table A Looks as follows
| TableA_ID | TableB_ID | PaymentMethod| ValuePayed |
|52 |1 | Method1 | 23,2 |
|21 |1 | Method2 | 23,2 |
|33 |2 | Method3 | 23,2 |
|42 |1 | Method2 | 14 |
|11 |14 | Method1 | 267 |
|42 |1 | Method2 | 14,7 |
|13 |32 | Method1 | 100,2 |
Table B Looks like this
| TableB_ID | TravelExpenses | OperatingExpense |
| 1 | 23 | 12 |
| 1 |234 | 24 |
| 2 | 12 | 7 |
| 1 |432 | 12 |
|14 |110 | 12 |
I am trying to create A measure Table (Table C) That Looks like like this:
| TableC_ID | TypeofCost | Amount |
| 1 | Method1 | 100,2 |
| 2 | Method2 | 52 |
| 3 | TravelExpenses | 7 |
| 4 | OperatingExpense| 12 |
| 5 | Method3 | 12 |
| 6 | OperatingExpense| 7 |
| 7 | Method3 | 12 |
(the Amount results are to be Summed and Columns - Employee, Month, TypeofCost Grouped)
So i pretty much have to Group not only by the PaymentMethod which i get from table A, but Also insert new Values in the Group ('TravelExpenses' and 'OperatingExpense')
Can anybody give me any Idea about how this can be done in SQL ? i have been desperately trying for quite some time but without succes, so i turned to you guys :)
Thanks to all of you in Advance!