Hey Kamal
Thank you that worked!! I had guessed CASE was the way to go, but could not
work out exactly where or how.
I really appreciate your help.
Regards
Dave
On Wednesday, 14 June 2017 07:19:45 UTC+1, Kamal Murthy wrote:
>
> Hi David,
>
> Try this:
>
> MATCH (movie:Movie {id: 1})
> OPTIONAL MATCH (me:User {id: 0})-[:SIMILAR]-(:User)-[rating:RATED]->(movie)
> UNWIND (CASE WHEN rating.recommend IS NULL then [0] else rating.recommend
> end) AS ids
> OPTIONAL MATCH (related:Movie) WHERE related.id = ids
> WITH DISTINCT movie, related, count(related) AS countRelated ORDER BY
> countRelated DESC
> RETURN DISTINCT movie,
> CASE WHEN related.id IS NULL THEN null else
> collect(DISTINCT {name:related.name, id:related.id, count:countRelated}) END
> AS related;
>
> This worked for me and displayed movie, Matrix.
>
> If you change the RETURN statement to:
>
> RETURN DISTINCT movie.name as Movie,
> CASE WHEN related.id IS NULL THEN null else
> collect(DISTINCT {name:related.name, id:related.id, count:countRelated}) END
> AS related;
>
> Result: Matrix, null
>
>
> -Kamal
>
> On Tuesday, June 13, 2017 at 4:58:48 PM UTC-7, Dave Clissold wrote:
>>
>> Have created the query and data in a console here
>>
>> http://console.neo4j.org/?id=y6ysgs
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.