I'm trying to make a cypher query which does the following
My attempted code looks like this to extract list of top 10 organisations is:
MATCH (org)
WHERE org.revenueCurrency = 'USD'
WITH org as topCompany
ORDER by topCompany.revenue desc LIMIT 10
RETURN topCompany
however not sure how to return to True or False if a company is in the top 10
This is one way:
MATCH (org)
WHERE org.revenueCurrency = 'USD'
WITH org
ORDER by org.revenue DESC
WITH COLLECT(org) AS orgs
UNWIND [i IN RANGE(0, SIZE(orgs)-1) | {org: orgs[i], top10: i < 10}] AS result
RETURN result
The top10
property of each result
row will be a boolean.
[UPDATE]
If you want each result row to be "flat" instead of a map, use this altered RETURN
clause:
RETURN result.org AS org, result.top10 AS top10