1
I have the following table quotations
that serves to fetch the totals of various budgets. And each budget has one piece (part_id
) which can have several:
+---------+-------------+----------+-----------------+
| part_id | alternative | revision | totals |
+---------+-------------+----------+-----------------+
| 1 | 1 | 0 | 252.22 |
| 2 | 0 | 0 | 452 |
| 1 | 1 | 1 | 270 |
| 1 | 2 | 2 | 250 |
| 1 | 2 | 3 | 250 |
+---------+-------------+----------------------------+
In the table, I want to sum up all the totals, but taking into account the following rules:
- part_id and alterantive is like a separate budget
- If there is more than one revision (revision
), I’ll get the total of the last revision.
I mean, initially I need to take the following:
+---------+-------------+----------+-----------------+
| part_id | alternative | revision | totals |
+---------+-------------+----------+-----------------+
| 2 | 0 | 0 | 452 |
| 1 | 1 | 1 | 270 |
| 1 | 2 | 3 | 250 |
+---------+-------------+----------------------------+
That is, in order to get the last revision for each alternative, I want to add the final total, which would be 972.
thank you very much!
– pc_oc