修改密码

请输入密码
请输入密码 请输入8-64长度密码 和 email 地址不相同 至少包括数字、大写字母、小写字母、半角符号中的 3 个
请输入密码
提交

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

服务器的MAC地址

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
申请天数
审批时间
过期时间
MAC地址
申请理由
审核信息
关闭
基础信息
  • 用户昵称:
  • 手机号:
  • 公司名称:
  • 公司邮箱:
  • 地区:
  • 语言:
修改密码
申请证书

当前未申请证书.

申请证书
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

ProductName CreateTime ID Price File
ProductName CreateTime ID Price File

No Invoice

v5.0
搜索
    v5.0

      GROUP BY

      概述

      GROUP BY子句将别名代表的数据行按指定的属性进行分组,分组后各组保留仅一行数据,其余行舍弃。GRIUP BY子句常与聚合、排序等操作配合使用。

      语法

      GROUP BY <expression> as <alias>, <expression> as <alias>, ...
      
      • <expression>是分组依据;如果使用了多个别名,它们必须同源,此时按照从左到右的顺序逐级进行分组
      • <alias>是为分组依据定义的别名,可省略

      例如,对以下路径查询产生的数据流进行多重分组。先按照起点n1的形状分组,再按照终点n2的颜色分组,然后统计各组的路径数量:

      n(as n1).re().n(as n2) as path
      group by n1.shape, n2.color
      return path, count(path)
      

      示例

      示例图集

      在一个空图集中,依次运行以下各行语句创建示例图集:

      create().node_schema("country").node_schema("movie").node_schema("director").edge_schema("filmedIn").edge_schema("direct")
      create().node_property(@*, "name")
      insert().into(@country).nodes([{_id:"C001", _uuid:1, name:"France"}, {_id:"C002", _uuid:2, name:"USA"}])
      insert().into(@movie).nodes([{_id:"M001", _uuid:3, name:"Léon"}, {_id:"M002", _uuid:4, name:"The Terminator"}, {_id:"M003", _uuid:5, name:"Avatar"}])
      insert().into(@director).nodes([{_id:"D001", _uuid:6, name:"Luc Besson"}, {_id:"D002", _uuid:7, name:"James Cameron"}])
      insert().into(@filmedIn).edges([{_uuid:1, _from_uuid:3, _to_uuid:1}, {_uuid:2, _from_uuid:4, _to_uuid:1}, {_uuid:3, _from_uuid:3, _to_uuid:2}, {_uuid:4, _from_uuid:4, _to_uuid:2}, {_uuid:5, _from_uuid:5, _to_uuid:2}])
      insert().into(@direct).edges([{_uuid:6, _from_uuid:6, _to_uuid:3}, {_uuid:7, _from_uuid:7, _to_uuid:4}, {_uuid:8, _from_uuid:7, _to_uuid:5}])
      

      组内聚合

      本例查找“国家-[]-电影-[]-导演”2步路径,按导演进行分组后,统计每组的路径条数:

      n({@country}).e().n({@movie}).e().n({@director} as n)
      group by n
      return table(n.name, count(n))
      

      |     n.name    | count(n) |
      |---------------|----------|
      | Luc Besson    | 2        |
      | James Cameron | 3        |
      

      如果要进行组内聚合运算,执行聚合运算的子句必须紧挨在GROUP BY子句后。

      多重分组

      本例查找“国家-[]-电影-[]-导演”2步路径,按国家和导演进行分组后,统计每组的路径条数:

      n({@country} as a).e().n({@movie}).e().n({@director} as b)
      group by a, b
      return table(a.name, b.name, count(a))
      

      | a.name |     b.name    | count(a) |
      |--------|---------------|----------|
      | France | Luc Besson    | 1        |
      | France | James Cameron | 1        |
      | USA    | Luc Besson    | 1        |
      | USA    | James Cameron | 2        |
      
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写