从东方数据库中的单个列删除重复的条目

SELECT medias,likes,description,createdon,title,postid,type,catagory,out('createdby').Name as Authors ,out('createdby').Nominator.Name as nominator, out('createdby').Nominator.school.Name as school from post where isDeleted=false order by createdon desc 

我必须从每一个职位获得细节。 这是我的关系

[post] -createdby-> [学生]

学生表有一个对象名提名者,其中包含提名者和提名者的详细信息,有一个叫学校的字段,里面包含学校的详细信息

当我运行上面的命令,我得到这样的输出

 [ { "@type": "d", "@rid": "#-2:15", "@version": 0, "medias": "/audience/fileupload/uploads/images/d5f1c692c0a01bd0d308b0cc3aa090cb.jpg", "likes": 1, "description": "This is art of rabbit ", "createdon": "2017-10-23 22:00:27", "title": "Rabbit", "postid": "0hLU1", "type": "photo", "catagory": "Art", "Authors": [ "SONISHA M" ], "nominator": [ "karthikairani j" ], "school": [ "Panchayat union middle school,keelamelkudi" ] }, { "@type": "d", "@rid": "#-2:12", "@version": 0, "medias": "/audience/fileupload/uploads/images/fd1fe7227d1e6d6bfd455dffddb41db9.jpg", "likes": 1, "description": "This post of multiple students work on global warming issues ", "createdon": "2017-10-23 20:17:55", "title": "Global warming ", "postid": "BwOk7", "type": "photo", "catagory": "Art", "Authors": [ "BALANIKUMAR M", "YUVARAJ R", "SOBIK RAJ C", "KALIDASS R" ], "nominator": [ "Arokia raj", "Arokia raj", "Arokia raj", "Arokia raj" ], "school": [ "Panchayat union middle school,keelamelkudi", "Panchayat union middle school,keelamelkudi", "Panchayat union middle school,keelamelkudi", "Panchayat union middle school,keelamelkudi" ] } 

许多提名者可以由许多学生完成一个单一的职位

那么怎么过滤呢也只能显示出同样出现在学校的单名提名人名字呢

我怎样才能改变我的代码来获得像这样的输出有什么办法可以使它更有效率

 [ { "@type": "d", "@rid": "#-2:15", "@version": 0, "medias": "/audience/fileupload/uploads/images/d5f1c692c0a01bd0d308b0cc3aa090cb.jpg", "likes": 1, "description": "This is art of rabbit ", "createdon": "2017-10-23 22:00:27", "title": "Rabbit", "postid": "0hLU1", "type": "photo", "catagory": "Art", "Authors": [ "SONISHA M" ], "nominator": [ "karthikairani j" ], "school": [ "Panchayat union middle school,keelamelkudi" ] }, { "@type": "d", "@rid": "#-2:12", "@version": 0, "medias": "/audience/fileupload/uploads/images/fd1fe7227d1e6d6bfd455dffddb41db9.jpg", "likes": 1, "description": "This post of multiple students work on global warming issues ", "createdon": "2017-10-23 20:17:55", "title": "Global warming ", "postid": "BwOk7", "type": "photo", "catagory": "Art", "Authors": [ "BALANIKUMAR M", "YUVARAJ R", "SOBIK RAJ C", "KALIDASS R" ], "nominator": [ "Arokia raj" ], "school": [ "Panchayat union middle school,keelamelkudi" ] } 

       

网上收集的解决方案 "从东方数据库中的单个列删除重复的条目"

尝试这个:

  SELECT medias,likes,description,createdon,title,postid,type,catagory,out('createdby').Name as Authors ,DISTINCT(nominator) as nominator, DISTINCT(school) as school from (SELECT medias,likes,description,createdon,title,postid,type,catagory,out('createdby').Name as Authors ,out('createdby').Nominator.Name as nominator, out('createdby').Nominator.school.Name as school from post where isDeleted=false order by createdon desc unwind nominator,school)