I get a list of values like the following:
| Name | Version | Value | Key | 
|---|---|---|---|
| N1 | 1.0 | 1 | K1 | 
| N1 | 1.0 | 1 | K2 | 
| N1 | 1.2 | 2 | K1 | 
| N1 | 1.2 | 1 | K2 | 
| N2 | 1.0 | 0 | K1 | 
| N2 | 1.0 | 0 | K2 | 
I just need the newest (highest version) key-value pairs of every name.
The result would be in this case:
| Name | Version | Value | Key | 
|---|---|---|---|
| N1 | 1.2 | 2 | K1 | 
| N1 | 1.2 | 1 | K2 | 
| N2 | 1.0 | 0 | K1 | 
| N2 | 1.0 | 0 | K2 | 
This is how the statement currently looks like.
I already had to split the results into single key-value pairs.
The reason is, I'm using them in Zoho-Analytics for generating graphs.
SELECT inside.* FROM 
(SELECT
         "Name",
         Version,
         to_integer(k1) as Value,
         'k1' as key
FROM  "RD" 
UNION
SELECT
         "Name",
         Version,
         to_integer("k2") as value,
         'k2' as key
FROM  "RD"   order by Version, "Name" asc
) as inside
 
     
    