I have a data table like the following example. I want to get the Sum of the column 'price'. The problem is, that i have the same data ('id') multiple times, which is updated from the program multiple times, there i only want the newest data entry.
f.e. the data
id | price | updatedate |
---|---|---|
1 **** | 20 | 11.07.2023 |
1 | 25 | 08.07.2023 |
1 | 85 | 06.07.2023 |
2 | 70 | 10.07.2023 |
2 **** | 15 | 11.07.2023 |
3 | 50 | 01.07.2023 |
3 **** | 90 | 11.07.2023 |
3 | 60 | 07.07.2023 |
So in this example, i want to sum the **** rows, because this are the newest data entrys for every id
I'm trying to search an SQL Function to get the sum of these values (price column), which is here 20 + 15 + 90 = 125
If i try GROUP BY, the result is given in three rows for every id und sums up every data row with this id.
SELECT SUM (price) FROM table GROUP BY id
but that isn't working....