-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Graph Data Processing with Cypher
By :

Now, let us build on the previous query and say we only want to return drugs that have more than 100 patients associated with them. This is the scenario in which the WHERE
clause would come into the picture.
The Cypher query looks like this:
MATCH (d:Drug)<-[:HAS_DRUG]-()<-[:HAS_ENCOUNTER]-(p) WITH DISTINCT d, p WITH d.description as drug, count(p) as patients WHERE patients > 100 RETURN drug, patients
To achieve what we want, we changed the query as shown in the highlighted section. We have to use the WITH
clause first to collect the data and then apply a filter using the WHERE
clause to prevent the data from being returned:
Figure 5.5 – Drugs with more than 100 patients associated with them
The preceding screenshot shows the response. We can see there are only 10 drugs that have more than 100 patients who have a prescription for them.
We can also use SKIP
and LIMIT
to filter the data being...