Assume we've created a graph inside the database with the subsequent information.
Count
The depend() characteristic is used to count number the number of rows.
Syntax
Following is the syntax of the rely feature.
MATCH (n { name: 'A' })-->(x)
RETURN n, count(*)
Example
Following is a pattern Cypher Query which demonstrates using the count number() function.
Match(n{name: "India", result: "Winners"})--(x)
RETURN n, count(*)
To execute the above query, perform the subsequent steps −
Step 1 − Open the Neo4j computer App and start the Neo4j Server. Open the built-in browser app of Neo4j the usage of the URL http://localhost:7474/ as shown in the following screenshot.
Step 2 − Copy and paste the preferred query in the greenback spark off and press the play button (to execute the query) highlighted within the following screenshot.
Result
On executing, you'll get the following result.
Group Count
The COUNT clause is likewise used to rely the agencies of courting kinds.
Example
Following is a pattern Cypher Query which counts and returns the number of nodes collaborating in each relation.
Match(n{name: "India", result: "Winners"})-[r]-(x)
RETURN type (r), count(*)
To execute the above question, carry out the subsequent steps −
Step 1 − Open the Neo4j laptop App and start the Neo4j Server. Open the integrated browser app of Neo4j the usage of the URL http://localhost:7474/ as proven within the following screenshot.
Step 2 − Copy and paste the favored query within the greenback spark off and press the play button (to execute the question) highlighted inside the following screenshot.
Result
On executing, you may get the following end result.