DISTINCT makes no sense with aggregation

I think this should be good enough for your needs

Or if you need the individual labels

MATCH (n)-[r]->(m)
RETURN labels(n) as labelsn, labels(m) as labelsm,type(r) as typer, count(*) AS 
 countr

MATCH (n)-[r]->(m)
UNWIND labels(n) as labelsn
UNWIND labels(m) as labelsm
RETURN labelsn, labelsm, type(r) as typer, count(*) AS  countr

Michael

> Am 14.05.2015 um 08:17 schrieb Tom Zeppenfeldt <[email protected]>:
> 
> Sumit, 
> 
> yes it works, but if I want to order the results for instance on the basis of 
> the first label, i need to access nrms[0][0] . and that's where it fails.
> 
> 
> 
> 
> Met vriendelijke groet / With kind regards
> 
> 
> 
> Ir. T. Zeppenfeldt
> van der Waalsstraat 30
> 6706 JR  Wageningen
> The Netherlands
> 
> Mobile: +31 6 23 28 78 06
> Phone: +31 3 17 84 22 17
> E-mail: [email protected] <mailto:[email protected]>
>  <mailto:[email protected]>Web: www.ophileon.com 
> <http://www.ophileon.com/>
> Twitter: tomzeppenfeldt
> Skype: tomzeppenfeldt
> 
> 2015-05-14 3:03 GMT+02:00 Sumit Gupta <[email protected] 
> <mailto:[email protected]>>:
> Hi Tom,
> 
> your query works fine without "Limit 1" too. it shows all the unique 
> combinations of "labelsn, labelm and typer", which is exactly your scope.
> 
> And that's true that lablesn is not a collection, so what is the problem? or 
> what is not working?
> 
> Thanks,
> Sumit
> 
> 
> On Wednesday, 13 May 2015 03:47:12 UTC+5:30, Tom Zeppenfeldt wrote:
> In order to make a meta-model, i'd like to know what kind of nodes , rels are 
> present in a db, as well as counts. 
> 
> Doing this
> 
> 
> MATCH (n)-[r]->(m)
> WITH DISTINCT [labels(n),labels(m),type(r)] AS nrms, count(*) AS  countr
> WITH nrms[0] AS labelsn, nrms[1] AS labelsm, nrms[2] AS typer, countr
> RETURN labelsn,labelsm,typer,countr
> 
> works fine. with a LIMIT 1, the API returns this
> 
> 
> {
>     "columns": [
>         "labelsn",
>         "labelsm",
>         "typer",
>         "countr"
>     ],
>     "data": [
>         [
>             [
>                 "Somelabel",
>                 "Diagram"
>             ],
>             [
>                 "View"
>             ],
>             "CONTAINS",
>             2
>         ]
>     ]
> }
> 
> However, the "labelsn" and  "labelsm" in the RETURN don't seem to be 
> collections. At least, I cannot do labelsn[0] or  length(labelsn)
> 
> Accessing nrms[0][0] also produces an error.
> 
> Running version 2.1.2
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to