Athena - SQL 按订单计数获取客户计数

发布于 2025-01-13 04:07:31 字数 392 浏览 2 评论 0原文

我有一个包含客户计数和订单计数的表,如下所示:

Customer   Order_Count
  A               5
  B               7
  C              5
  D              4
  E              1
  F               1
  G              1

如何编写 SQL 来按订单获取客户计数?结果如下:

 Orders      Customer_Count
   7                1
   5                 2
   4                 1
   1                  3

I have a table with custome rcount and order count as below:

Customer   Order_Count
  A               5
  B               7
  C              5
  D              4
  E              1
  F               1
  G              1

How do I write the SQL to get customer count by orders? The result would be as below:

 Orders      Customer_Count
   7                1
   5                 2
   4                 1
   1                  3

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫腻 2025-01-20 04:07:31

您使用 Group by 并获取客户数量,如下所示:

select order_count, count(customer) customer_count
from your_table
group by customer

you use Group by and get count of customer like this:

select order_count, count(customer) customer_count
from your_table
group by customer
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文