Retrieving the most recent entry for the user is a common problem that is often tagged with the greatest-n-per-group
in Stack Overflow. I suggest creating a VIEW for this, although this is not strictly necessary.
CREATE VIEW LatestKeyValue AS SELECT k1.* FROM KeyValue AS k1 LEFT OUTER JOIN KeyValue AS k2 ON (k1.UUID_User, k1.Variable) = (k2.UUID_User, k2.Variable) AND k1.DateSet < k2.DateSet WHERE k2.DateSet IS NULL
You can then expand this for each variable you need in several ways, such as:
SELECT UUID_User, MAX(CASE Variable WHEN 'FirstName' THEN Value END) AS FirstName, MAX(CASE Variable WHEN 'LastName' THEN Value END) AS LastName FROM LatestKeyValue GROUP BY UUID_User
source share