Hi everyone,
unfortunately I could not find an answer to this question in the forum yet. I have a table X associated with table Y. I would like to primarily take the cost from table Y (the up-to-date cost values are to be found here) and if it is not available, only then from table X.
For some IDs from table X the entry in table Y is missing and theerefore the cost data can only be found in table X. Sample data:
Table Name | ID | Monthly_Cost_X |
X | 1 | 100 |
X | 2 | 450 |
X | 3 | 200 |
Table Name | ID | Monthly_Cost_Y |
Y | 1 | 100 |
| | |
Y | 3 | 200 |
For this purpose I was trying to use the MissingCount function, however, this only works with aggregates. What I would finally need in the end is something like this:
Sum(if(MissingCount(Monthly_Cost_Y)>0, Monthly_Cost_X, Monthly_Cost_Y))
For the sample date I would expect the following sums: ID 1:100, ID 2: 450, ID 3: 200.
Could you please suggest me a solution to this problem?
Thanks and BR
Máté