I have difficulties forming the right query for this problem. It's probably not very hard though. I was given a hint and told to redo it using nested queries though, but need some help.
Basically I need to do this:
- Retrieve a list of all the texts known as ChargeId.
- There are many of each, so each should have the latest date on.
- If a ChargeId are there more than once with the latest date, then they are versioned. So take the one with the latest version in that case.
Basically these are electricity prices and they are changed in a Windows form window. The date is when they are valid from. And if the user changes some of them without changing the date, then it just gets a newer version. Version 3 becomes version 4. Here is my attempt which obviously returns too much because each ChargeId appears more than one time.
Note here that all the relevant prices has version 4. They do not have to have the same version or the same date. It is just simply "retrieve all prices with the latest date for each. If more than one ChargeId line is there, then take the one with highest version."
Edit: I thought this would work, but not all ChargeId's are there.

