Couchbase 中文教程
  • Introduction
  • Couchbase 简介
  • Couchbase 应用场景
  • Couchbase 安装
  • Couchbase UI
  • 使用Node.js客户端
    • 安装与入门
    • 基本操作
      • CRUD 基本操作
      • 计数器操作
      • 过期时间操作
      • 加锁/解锁操作
      • Map方式操作(针对文档字段)
      • List链表方式操作
      • Queue队列方式操作
      • Set集合方式操作
      • append 与 prepend操作
    • N1QL操作
    • Sub-Document 部分更新操作
  • N1QL 基础操作教程
    • 第一章:N1QL基础
      • 测试数据
      • 1.AS 字段别名
      • 2.SELECT,FROM,WHERE
      • 3.文档,而不是行
      • 4.文档元数据
      • 5.简单算术运算
      • 6.ROUND(),TRUNC()函数
      • 7.字符串拼接
      • 8.WHERE条件过滤
      • 9.LIKE, NOT LIKE匹配
      • 10.Select DISTINCT
      • 11.判断 NULL和MISSING值
      • 12.匹配的元素与任何嵌套的数组
      • 13.AND,OR 组合多个条件
      • 14.USE KEYS 关键词匹配查询
      • 15.数组操作和切片
      • 16.快速回顾
      • 17.排序 ORDER BY
      • 18.LIMIT 和 OFFSET
      • 19.COUNT() , AVG() 聚合函数
      • 20.GROUP BY 分组
      • 21.HAVING 分组数据的过滤
      • 22.数组简约式
      • 23.回顾
    • 第二章:Joins 连接查询
      • 测试桶数据
      • 24.JOIN 子句
      • 25.Left outer JOINs 左外连接
      • 26.NEST
      • 27.UNNEST
      • 28.组合JOIN
    • 第三章:DML语句
      • 29.CURL 语句
      • 30.DELETE 删除操作
      • 31.UPDATE 更新操作
    • 案例分析 I:电子商务
      • 32.介绍说明
      • 33.Shopper - 浏览产品页面
      • 34.Shopper - 产品categories列表
      • 35.Shopper - 浏览和搜索产品
      • 36.Shopper - 列出category下的产品清单
      • 37.Shopper - 在栏目中找到最流行的一些产品
      • 38.Shopper - 浏览产品和排序结果
      • 39.Shopper - 购买促销活动产品
      • 40.Shopper - 列出了十大最畅销的产品
      • 41.Shopper - 列出评价最高的产品
      • 42.Merchant -为一个购买订单做准备
      • 43.Merchant - 找到最有价值的顾客
      • 44.Merchant - 客户的地区分布报告
      • 45.Merchant - 每月报告活动的客户
      • 46.Merchant - 识别评分较低的产品
      • 47.Merchant - 生成上月销售报告
      • 48.Merchant - 大订单
    • 案例分析 II:社交游戏
      • 49.介绍说明
      • 50.组装和加载用户配置信息
      • 51.列出一个用户发送的消息
      • 52.生成记分牌
      • 53.生成全球排行榜
      • 54.列出朋友
  • N1QL 5.5 进阶教程
    • COUCHBASE 5.5:查询和索引特性概述
    • ANSI JOINs in N1QL
    • 索引分组和聚合
    • 索引分区
  • Couchbase 连接器
    • Elasticsearch
      • Elasticsearch 插件配置
      • 与Couchbase交互说明
      • 其他
  • CAS机制
  • 索引
  • 视图(view indexes)
  • API
  • 资料
  • 注意点
  • 数据导出
Powered by GitBook
On this page

Was this helpful?

  1. N1QL 基础操作教程
  2. 案例分析 I:电子商务

44.Merchant - 客户的地区分布报告

Previous43.Merchant - 找到最有价值的顾客Next45.Merchant - 每月报告活动的客户

Last updated 6 years ago

Was this helpful?

dimestore想推出一个区域营销活动,管理想要一个按照每个区域的客户数量按邮政编码分组的报告.

SELECT COUNT(customer) AS customerCount, state
FROM customer 
GROUP BY state
ORDER BY customerCount DESC

结果:

{
  "results": [
    {
      "customerCount": 27,
      "state": "NC"
    },
    {
      "customerCount": 24,
      "state": "FL"
    },
    {
      "customerCount": 23,
      "state": "VA"
    },
    {
      "customerCount": 23,
      "state": "IA"
    },
    {
      "customerCount": 21,
      "state": "TN"
    },
    {
      "customerCount": 21,
      "state": "OK"
    },
    {
      "customerCount": 20,
      "state": "KS"
    },
    {
      "customerCount": 19,
      "state": "AR"
    },
    {
      "customerCount": 19,
      "state": "IN"
    },
    {
      "customerCount": 19,
      "state": "WA"
    },
    {
      "customerCount": 19,
      "state": "CA"
    },
    {
      "customerCount": 19,
      "state": "HI"
    },
    {
      "customerCount": 19,
      "state": "GU"
    },
    {
      "customerCount": 19,
      "state": "WV"
    },
    {
      "customerCount": 19,
      "state": "ND"
    },
    {
      "customerCount": 19,
      "state": "CO"
    },
    {
      "customerCount": 18,
      "state": "MI"
    },
    {
      "customerCount": 18,
      "state": "TX"
    },
    {
      "customerCount": 18,
      "state": "MO"
    },
    {
      "customerCount": 18,
      "state": "UT"
    },
    {
      "customerCount": 18,
      "state": "IL"
    },
    {
      "customerCount": 18,
      "state": "NY"
    },
    {
      "customerCount": 17,
      "state": "AZ"
    },
    {
      "customerCount": 17,
      "state": "PA"
    },
    {
      "customerCount": 17,
      "state": "NE"
    },
    {
      "customerCount": 17,
      "state": "MP"
    },
    {
      "customerCount": 17,
      "state": "MA"
    },
    {
      "customerCount": 17,
      "state": "NV"
    },
    {
      "customerCount": 16,
      "state": "AA"
    },
    {
      "customerCount": 16,
      "state": "VT"
    },
    {
      "customerCount": 16,
      "state": "MS"
    },
    {
      "customerCount": 16,
      "state": "WI"
    },
    {
      "customerCount": 16,
      "state": "DE"
    },
    {
      "customerCount": 15,
      "state": "AE"
    },
    {
      "customerCount": 15,
      "state": "FM"
    },
    {
      "customerCount": 15,
      "state": "MT"
    },
    {
      "customerCount": 15,
      "state": "MH"
    },
    {
      "customerCount": 15,
      "state": "NH"
    },
    {
      "customerCount": 15,
      "state": "RI"
    },
    {
      "customerCount": 15,
      "state": "NJ"
    },
    {
      "customerCount": 15,
      "state": "WY"
    },
    {
      "customerCount": 15,
      "state": "SC"
    },
    {
      "customerCount": 15,
      "state": "LA"
    },
    {
      "customerCount": 14,
      "state": "KY"
    },
    {
      "customerCount": 14,
      "state": "CT"
    },
    {
      "customerCount": 14,
      "state": "ME"
    },
    {
      "customerCount": 14,
      "state": "NM"
    },
    {
      "customerCount": 14,
      "state": "OR"
    },
    {
      "customerCount": 13,
      "state": "VI"
    },
    {
      "customerCount": 13,
      "state": "DC"
    },
    {
      "customerCount": 13,
      "state": "ID"
    },
    {
      "customerCount": 13,
      "state": "AS"
    },
    {
      "customerCount": 12,
      "state": "AP"
    },
    {
      "customerCount": 12,
      "state": "AK"
    },
    {
      "customerCount": 12,
      "state": "GA"
    },
    {
      "customerCount": 12,
      "state": "OH"
    },
    {
      "customerCount": 12,
      "state": "PR"
    },
    {
      "customerCount": 11,
      "state": "MN"
    },
    {
      "customerCount": 11,
      "state": "AL"
    },
    {
      "customerCount": 9,
      "state": "MD"
    },
    {
      "customerCount": 9,
      "state": "SD"
    },
    {
      "customerCount": 8,
      "state": "PW"
    }
  ]
}