Cypher Query - Count function

Hello,
I tried to make a request but I'm having a bit of trouble with the cypher being new.
So my request in question: Calculate the number of apples which are in basket 1 and in basket 2 (knowing that apple, basket 1 and basket 2 are 3 different objects and that there is a relation of basket 1 -> apple and basket 2 -> apple)

I tried this :

MATCH (a:Apple)<-[:INCLUDE_ON]-(bO:BasketOne)-[:INCLUDE]->(bT:BasketTwo)

WITH a, bT, count(abT) as cnt

RETURN cnt;

But it doesnt works...
Thanks for your help!

Hello @Mastege and welcome to the Neo4j community :slight_smile:

Can you run this command and give us the result here?

CALL db.schema.visualization()

Regards,
Cobra

you reference a count(abT) but I do not see where we defined abT

Also But it doesnt works... ? Can you provide more specifics? You get a syntax error? you get wrong results? the query doesnt complete ?

Hi,
I resolve my problem with some search, that was the request i want, if you want to see it ->
MATCH (b1:Basket1)-[:INCLUDE_ON]->(a:Apple)<-[:INCLUDE_ON]-(b2:Basket2) RETURN B1.id as Basket1, b2.id as Basket2, count(a) as Apple_Number;

1 Like

Thanks for the help !