Select node with minimum value

Hi all,
I have a “movies” graph with “actor” and “movie” nodes. Movie nodes have date attribution.
I wanted to create a new relationship “First_appearence” from every actor node to the first movie the actor played.

I tried querying with min(date) and trying to relink it without any success.
Can anyone help me with it?

This simple example uses SYNTAX V2.

MinAccum<DATETIME> @firstAppearance;

A = {Actor.*};

A1 = SELECT a FROM A:a -(ACTED_IN>) - Movie:m
          ACCUM a.@firstAppearance += m.releaseDate;
1 Like

@markmegerian You are a Ninja. Just about to add this and you’re post popped up!! Thanks!!

1 Like

You both are Ninjas.


1 Like

Pay attention that you didn’t create a new link but rather added a new attribute to the node.
So I ended up adding the following. It works, but I am not sure that’s the correct way to do it…

MinAccum @firstAppearance;
A = {Actor.*};
A1 = select a
FROM A:a-(ACTED_IN)-Movie:m
ACCUM s.@firstAppearance += m.releaseDate;

// This is the addition

Res = Select m
FROM A:a-(ACTED_IN)-Movie:m
WHERE m.date_published == a.@firstAppearance

1 Like