I have a table with fields ID, action and value. ID is the record name, action is the identifier of what does the value represent. The values of ID in the table are duplicated with different actions and values.
Example:
ID action value
3603 1 78
3603 2 2
3603 3 1
5645 1 45
etc...
Now I would like to construct a select statement that would somehow get values where ID=3603 and the formula is (if action 1 then value*10, if action 2 then value*5 and if action 3 then value*2). The result for 3603 is 792.
On top of that I need this to be joined to another table where I have the same ID value (unique) and I need to order by this sum both tables…
Is that possible or should I do some cumulative table that holds this sums for each record? Problem is this is statistics calculations so every ID will get 3 inputs of the actions for every month and every year (monthly statistics).
to save in a historical table use: