I tried this but it is returning all the node names with dates in ascending order. But I want that the nodes with the least date should be returned. That is node A with date 08-2021 and node B with date 08-2021.
Hence, I just want the name of the nodes where the date is minimum. In this example there are 2 such nodes but in my graph DB there can be any number of nodes where date is minimum.
Try this:
match (b:Capacity)
where b.Available_Capacity<b.Required_Capacity
with min(b.date) as dt
match (a:Capacity)
where a.Available_Capacity<a.Required_Capacity
where a.date = dt
return a.name
You almost have it with this query, all you need to do is project, from the minItems structure, the elements of it you want. You could use RETURN [node IN minItems.items | node.name] as names, minItems.value as minDate to get the list of names associated with nodes that had the given minimum data value.