gzg
gzg

Reputation: 1489

DISTINCT, SKIP and LIMIT in Cypher Query

MATCH (n)
RETURN DISTINCT n
ORDER BY n.name
SKIP 5
LIMIT 10

When I write such a query, it will not always return 10 results because first the limitation is done and then DISTINCT command filters the results; so the DISTINCT command works on 10 results. How can I change this query to return DISTINCT results and then limits them to 10? I'd like to get 10 results every time.

Upvotes: 0

Views: 2252

Answers (1)

jjaderberg
jjaderberg

Reputation: 9952

Does this do what you want?

MATCH (n)
WITH DISTINCT n
    ORDER BY n.name
RETURN n
    SKIP 5
    LIMIT 10

Upvotes: 6

Related Questions