I have following set of data in a vertex of graph DB.
userID(PK) | product(CK) | usage(CK) | validFrom(CK) | validTo(CK) | lastUpdated (CK) | location | qty | uom |
1 | aa | 1 | 10/10/21 | 10/10/22 | 11/02/21 | SJC | 1 | LB |
1 | aa | 1 | 10/10/21 | 10/10/22 | 10/02/21 | HH | 2 | LB |
1 | bb | 1 | 10/10/21 | 10/10/22 | 11/02/21 | ABC | 1 | LB |
1 | bb | 1 | 10/10/21 | 10/10/22 | 10/02/21 | BCD | 40 | LB |
I will have to get the latest records based on the last updated date. The result should be below records.
1 | aa | 1 | 10/10/21 | 10/10/22 | 11/02/21 | SJC | 1 | LB |
1 | bb | 1 | 10/10/21 | 10/10/22 | 11/02/21 | ABC | 1 | LB |
Is it possible to get it through a gremlin query? I did try with the group by, but could not add more than one column. I need to have all the clustering keys in a group by except the last one. I will have to pick the latest last updated for each user,product, usage,validFrom and validTo group.
Do you recommend defining the graph schema in a different way? All I need the latest record for the given set of keys.