# Group more "JSON's" in one record

**URL:** <https://community.neo4j.com/t/group-more-jsons-in-one-record/20864>\
**Category:** Cypher\
**Created:** [July 1, 2020, 12:07pm UTC](https://community.neo4j.com/t/group-more-jsons-in-one-record/20864 "2020-07-01T12:07:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anthino12](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/anthino12/32/12214_2.png) [@anthino12](https://community.neo4j.com/u/anthino12)\
**Post date:** [July 1, 2020, 12:07pm UTC](https://community.neo4j.com/t/group-more-jsons-in-one-record/20864/1 "2020-07-01T12:07:20Z")

</div>

Hey, I have a data set with ~1 million nodes and 1 million relations. My goal now is to return all of the data using the neo4j and cypher(QL) but I get a lot of redundancy. My set contains Posts, Authors, Comments and InLinks. The relations are:

1. Post -\>WRITTEN\_BY-\>Author;
2. Comment -\>POSTED\_ON-\>Post;
3. InLinks -\>LINKS-\>Post.

My cypher is this:  
`match (p:Posts)-[:WRITTEN_BY]->(author), (c:Comments)-[:POSTED_ON]->(p), (i:InLinks)-[:LINKS]->(p) RETURN p as Post, c as Comment, i as Inlink, author LIMIT 100`  
and I get an output like:

```auto
Post Comment InLink Author
PostID1 CommentID1 InLinkID1 AuthorID1 (for example)
PostID1 CommentID1 InLinkID2 AuthorID1 (for example)
PostID1 CommentID2 InLinkID3 AuthorID1 (for example)
PostID1 CommentID2 InLinkID4 AuthorID1 (for example)
PostID1 CommentID1 InLinkID5 AuthorID1 (for example)

```

as you can see here, for the same Post and Author but different InLink and Comment I'm getting redundancy aka I'm getting data that is repeating non necessarily. What I'm trying to achieve is

```auto
Post Comment InLink Author
PostID1 CommentID1 InLinkID1 AuthorID1 (for example)
                    InLinkID2 AuthorID1 (for example)
                    InLinkID5 AuthorID1 (for example)
-------------------------------------------------------------------------
PostID1 CommentID2 InLinkID3 AuthorID1 (for example)
                    InLinkID2 AuthorID4 (for example)

```

Any tips on how to do this?  
Thank you

---

<div class="post-metadata">

**Author:** ![dominicvivek06](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dominicvivek06/32/5034_2.png) [@dominicvivek06](https://community.neo4j.com/u/dominicvivek06)\
**Post date:** [July 1, 2020, 12:13pm UTC](https://community.neo4j.com/t/group-more-jsons-in-one-record/20864/2 "2020-07-01T12:13:25Z")

</div>

you can use WITH statements along with COLLECT.

---

<div class="post-metadata">

**Author:** ![anthino12](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/anthino12/32/12214_2.png) [@anthino12](https://community.neo4j.com/u/anthino12)\
**Post date:** [July 1, 2020, 12:26pm UTC](https://community.neo4j.com/t/group-more-jsons-in-one-record/20864/3 "2020-07-01T12:26:03Z")

</div>

Thank you, I solved it with

```auto
match (p:Posts)-[:WRITTEN_BY]->(author), (c:Comments)-[:POSTED_ON]->(p), (i:InLinks)-[:LINKS]->(p) 
RETURN p as Post, collect(c) as Comments, collect(i) as InLinks, author 

```
