I have created the following query:
MATCH (n:Name)<-[r:HAS_NAME_VARIANT]-(p)-[r2:WORKS_AS]->(a)-[r4:ACTIVITY_TYPE]->(o:ProfessionsOntology),
(a)-[r3:ACTIVITY_FOUND_IN]->(s2)-[pr:PRODUCED_BY {role: "writer"}]->(p3)-[r8:HAS_NAME_VARIANT]->(n8)
WHERE n.NameID = $neodash_name_nameid
WITH r3, n8, o, s2, (s2.title + CASE WHEN size(r3.page) < 2 THEN "" ELSE ", p." + r3.page END + CASE WHEN size(r3.location) < 2 THEN "" ELSE ", " + r3.location END) AS sss, n8.Name AS Author, s2.language AS Language, s2.type AS Type, r3.qualification AS `Qualification`
RETURN o.Text AS Activity, sss AS `Source (title, page, location)`, Author, Type, Language, Qualification
which reads as follows:
MATCH (n:Name)<-[r:HAS_NAME_VARIANT]-(p)- ===> find a person
[r2:WORKS_AS]->(a)-[r4:ACTIVITY_TYPE] ===> who works as a "professionID"
[r4:ACTIVITY_TYPE]->(o:ProfessionsOntology), ===> this "professionID corresponds to "printer"
(a)-[r3:ACTIVITY_FOUND_IN]->(s2) "===> the information above was found in "book 1"
-[pr:PRODUCED_BY {role: "writer"}]->(p3)-[r8:HAS_NAME_VARIANT]->(n8) ===> written by "writer x"
Since one person can have many professions ( printer, publisher, seller) and this information can be found in multiple sources (book 1, book 2, etc.), the table should contain a list of all the professions of this person with their sources, in the following format:
Activity______________Source______________ Author
printer........................book 1......................writer x
printer........................book 2......................writer y
publisher...................book 1......................writer x
Instead, it lists all activities x sourcers x authors:
I've tried a host of options with split MATCHes, DISTINCT, COLLECT, etc. bu to no avail...
Any suggestions greatly appreciated!