Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Using LIMIT/SKIP/ORDER BY with UNION is only applied to the last union set #1879

wenic opened this Issue · 8 comments

6 participants


with the following cypher query;

MATCH (movie:com.test.domain.Movie) WHERE NOT (movie)<-[:RATED]-()
RETURN movie, 0.0 AS avgStars
MATCH (movie:com.test.domain.Movie)<-[r:RATED]-() WITH movie, avg(r.stars) AS avgStars
RETURN movie, avgStars

LIMIT is only applied to the result set of the last MATCH, so it will limit the last MATCH to 100 and include what ever rows the first MATCH returns.

Same happens when using SKIP and ORDER BY.


You can apply a separate limit / skip / oder by to the first match too


I think this is a valid feature request that I've been interested in as well. There's no way to apply a limit to the overall query (similarly, you can't aggregate over the UNION, etc.).


sorry, i should have said the expected results would be. As wfreeman says would be good if you could apply the skip, limit, order by to the overall query.

The original issue came across when I tried to make the results pagable, so instead of getting a page of 100 results I got 100+. The issue was more noticeable, for example when you apply order by on the movie.title; the list you get back, the first half is unsorted and the second half is sorted.

So if you apply an order by on the first match as well, what you get back is two ordered lists joined together so you get [(A-Z)(A-Z)] and not the overall [A-Z] list.


Yes, this is a current known limitation in the use of UNION. We'll look at ways to improve it in future.


Thanks, would be good to see it working. Had a read around stackoverflow, but haven't found an alternative query that could do the same thing.


Is this feature is released?


Can we have approx estimation time?



Will track this in #2725

@cleishm cleishm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.